Skip to content

Instantly share code, notes, and snippets.

@iNem0o
Created May 22, 2013 12:24
Show Gist options
  • Save iNem0o/5627152 to your computer and use it in GitHub Desktop.
Save iNem0o/5627152 to your computer and use it in GitHub Desktop.
Quick-and-dirty benchmark
<?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