Created
July 24, 2014 09:17
-
-
Save ivankravchenko/7467505c1110d305f12f to your computer and use it in GitHub Desktop.
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 | |
error_reporting(E_NONE); | |
$cnt = 100; | |
$t1 = microtime(true); | |
$a = 4; | |
for ($i=1; $i<=$cnt; $i++) { if ($a) { 1+1; } } | |
$t2 = microtime(true); | |
unset($a); | |
for ($i=1; $i<=$cnt; $i++) { if ($a) { 1+1; } } | |
$t3 = microtime(true); | |
$a = array(1, 2, 3); | |
for ($i=1; $i<=$cnt; $i++) { if ($a[2]) { 1+1; } } | |
$t4 = microtime(true); | |
unset($a[2]); | |
for ($i=1; $i<=$cnt; $i++) { if ($a[2]) { 1+1; } } | |
$t5 = microtime(true); | |
$time1=$t2-$t1; | |
$time2=$t3-$t2; | |
$time3=$t4-$t3; | |
$time4=$t5-$t4; | |
printf("Test run 1 : %1.3f ms\n", $time1*1000); | |
printf("Test run 2 : %1.3f ms\n", $time2*1000); | |
printf("Test run 3 : %1.3f ms\n", $time3*1000); | |
printf("Test run 4 : %1.3f ms\n", $time4*1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment