<?php | |
function fib($n) | |
{ | |
if ($n <= 2) | |
return 1; | |
else | |
return fib($n-1) + fib($n-2); | |
} | |
function microtime_float() | |
{ | |
list($usec, $sec) = explode(" ", microtime()); | |
return ((float)$usec + (float)$sec); | |
} | |
function medir() | |
{ | |
$a=microtime(true); | |
//echo $a." <br> "; | |
//echo " <br> ";echo " <br> "; | |
test(); | |
$b=microtime(true); | |
//echo $b." <br> "; | |
//echo " <br> ";echo " <br> "; | |
//echo " <br> ";echo " <br> "; | |
informe($b-$a); | |
} | |
function test() | |
{ | |
$n = 32; | |
printf("fib(%d) = %d\n", $n, fib($n, 2)); | |
echo " <br> ";echo " <br> "; | |
} | |
function informe($r) | |
{ | |
echo " <br> ";echo " <br> "; | |
echo "PERFORMANCE ".($r); | |
$ipServer = $_SERVER['SERVER_NAME']; | |
$urlRootAPACHE = "http:\/\/" . $ipServer . "/"; | |
$urlRootHHVM = "http:\/\/" . $ipServer . ":8080/"; | |
echo " <br> "; | |
echo " <br> "; | |
echo " <br> "; | |
echo "APACHE + "; | |
echo "<a href='./opc.php' > OPCACHE </a>"; | |
echo " <br> "; | |
echo "<a href='" . $urlRootAPACHE . "test-fast.php' > TEST 1 </a>"; | |
echo " <br> "; | |
echo "<a href='" . $urlRootAPACHE . "test-fast-2.php' > TEST 2 </a>"; | |
echo " <br> "; | |
echo " <br> "; | |
echo " <br> "; | |
echo "HHVM "; | |
echo " <br> "; | |
echo "<a href='" . $urlRootHHVM . "test-fast.php' > TEST 1 </a>"; | |
echo " <br> "; | |
echo "<a href='" . $urlRootHHVM . "test-fast-2.php' > TEST 2 </a>"; | |
} | |
medir(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment