Created
May 22, 2013 12:24
-
-
Save iNem0o/5627152 to your computer and use it in GitHub Desktop.
Quick-and-dirty benchmark
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 | |
$root = 'var'; | |
for($i = 0;$i <= 10; $i++) { | |
$varName = $root.$i; | |
$$varName = $i; | |
} | |
$timer = microtime(true); | |
for($j = 0;$j <= 100; $j++) { | |
$var = $var1.' qsd '.$var2.' qsd '.$var3.' qsd '.$var4.' qsd '.$var5.' qsd '.$var6.' qsd '.$var7.' qsd'; | |
} | |
$fin = microtime(true); | |
echo "<pre>".$var.'</pre>'; | |
echo "<br>durée concat avec . : ".round(($fin-$timer)*1000,4)." ms"; | |
$timer = microtime(true); | |
for($j = 0;$j <= 100; $j++) { | |
$var = "$var1 qsd $var2 qsd $var3 qsd $var4 qsd $var5 qsd $var6 qsd $var7 qsd"; | |
} | |
$fin = microtime(true); | |
echo "<pre>".$var.'</pre>'; | |
echo "<br>durée concat avec les double quote : ".round(($fin-$timer)*1000,4)." ms"; | |
$timer = microtime(true); | |
for($j = 0;$j <= 100; $j++) { | |
$var = implode('',array($var1,' qsd ',$var2,' qsd ',$var3,' qsd ',$var4,' qsd ',$var5,' qsd ',$var6,' qsd ',$var7,' qsd')); | |
$fin = microtime(true); | |
} | |
echo "<pre>".$var.'</pre>'; | |
echo "<br>durée concat avec implode : ".round(($fin-$timer)*1000,4)." ms"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment