Created
October 27, 2013 14:06
-
-
Save fwolf/7182566 to your computer and use it in GitHub Desktop.
Speed benchmark for PHP single-quote VS double-quote. Result: almose same.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$blah="blah"; $s=microtime(true); for($i=0;$i<100000;$i++) 'omgwtf'.$blah."\n"; echo microtime(true)-$s . "\n"; $s=microtime(true); for($i=0;$i<100000;$i++) "omgwtf{$blah}\n"; echo microtime(true)-$s . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://groups.google.com/forum/#!topic/make-the-web-faster/3fvoLdgECMw
Nothing is wrong with the statement, you're just not interpreting it
very accurately...the difference is very small and slightly in the
favor of single quotes whenever a handful of variables are used.
However, when no variables are used, double quotes may be faster
because of implementation details in the engine.
These micro-optimizations can't get you more than 1 or 2 extra
requests per second done on a box...if that request has several tens
of thousands of variable interpolation operations. This is a LOT of
work for no real reward. Caching solutions and configuration tweaks
yield much higher results.