Created
February 10, 2012 15:58
-
-
Save daGrevis/1790459 to your computer and use it in GitHub Desktop.
[bench] String concatenation versus printing string
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 | |
echo '<div style="display: none;">'; | |
$s1 = microtime(true); | |
for ($i = 0; $i < 1000000; ++$i) { | |
echo 'a'.'b'; | |
} | |
$e1 = microtime(true) - $s1; | |
$s2 = microtime(true); | |
for ($i = 0; $i < 1000000; ++$i) { | |
echo 'a', 'b'; | |
} | |
$e2 = microtime(true) - $s2; | |
echo '</div>'; | |
echo '<br /><br />'; | |
echo $e1; | |
echo '<br />'; | |
echo $e2; | |
echo '<br />'; | |
echo $e1 - $e2; | |
// esmu kruts |
Author
daGrevis
commented
Feb 10, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment