Live data from Hacker News

PHP Team Responds to Google's PHP Tips

groups.google.com

11–20 of 40 posts

Re: PHP Team Responds to Google's PHP Tips

#11

"When simple strings with no variables in them are used, the performance is clearly better with double-quoted strings due to implementation details in the engine." Is there any way this could be true except that they went out of their way to slow down single-quoted strings? How could it possibly be slower to do fewer steps?

I've found that the only way to get accurate information about performance is to test it myself or use a source that actually gives data. I tested this myself a while ago and found no detectable difference between single and double quotes. (And if I hadn't done this, I'd know not to trust this post:) )

Re: PHP Team Responds to Google's PHP Tips

#15
Even if all the tips were valid, the performance gain is tiny in comparison to simply installing an opcode cache (APC/Zend/etc).

And even after installing the opcode cache, performance for many web apps doesn't improve much as the bottleneck is often in the DB. Caching DB results where possible (pretty simple to implement with your own code or an external library) often results in far greater performance gain than any type of code optimization. If you can actually cache the resulting HTML (all or parts), even better.

Re: PHP Team Responds to Google's PHP Tips

#16

Despite google dropping ball on this one, some good may come from it having spurred Gwynne Raskind's reply: Anyone out there writing PHP might find real optimization value from Alex Songe comments, concluding with (following Gwynne's article): Good resources (written by the guys who actually work on the php engine): http://ilia.ws/files/phptek2007_performance.pdf (13 MB) http://ilia.ws/files/phpquebec_2009.pdf ( 1.1…

That was the most important comment I had seen. I'm kind of surprised Gwynne's did not include similar links.

Re: PHP Team Responds to Google's PHP Tips

#17

Earlier quoted context omitted.

If I was going to guess, I'd say that double quoted strings are passed to a different "engine" than the single quotes, and perhaps over time the double quote engine has received better optimization.

Yeah, thats what I also figured but, really, how much can you optimize a constant string literal (which I'm given to understand the single-quote thing is)? Must be some kind of caching optimization and not really something that saves CPU cycles

Single quotes aren't a constant string literal, because they have to parse \'.

Re: PHP Team Responds to Google's PHP Tips

#18
post #7

I (naively) read Google's performance tips as fact and wouldn't have thought twice about it. Lesson learned.

Their tips on how to optimize HTML pages are similarly silly. They suggest removing all end tags, as well as start and end tags that aren't strictly necessary according to the HTML standard, such as the 'html', 'head' and 'body' tags.

Saving a byte here and there for the sake of transfer-speed, without a thought for rendering speed or maintainability, is apparently ideal.

Re: PHP Team Responds to Google's PHP Tips

#19
post #15

Even if all the tips were valid, the performance gain is tiny in comparison to simply installing an opcode cache (APC/Zend/etc). And even after installing the opcode cache, performance for many web apps doesn't improve much as the bottleneck is often in the DB. Caching DB results where possible (pretty simple to implement with your own code or an external library) often results in far greater performance gain than an…

In very high volumes, tiny performance gains change user behavior.

Re: PHP Team Responds to Google's PHP Tips

#20

"When simple strings with no variables in them are used, the performance is clearly better with double-quoted strings due to implementation details in the engine." Is there any way this could be true except that they went out of their way to slow down single-quoted strings? How could it possibly be slower to do fewer steps?

That does sound counter intuitive. But even if performance differences are negligible, I still find it much more efficient, or at least ergonomically comfortable, to use single quotes with only one finger/keystroke, no need for shift. Same reason I dislike PHP's arrow -> for methods/properties, that's three keys right there, vs. just a dot in other languages.
Post reply on HN