@ 2014-01-26T05:26:48Z <?php
/*
##########################################################################
# PHP Benchmark Performance Script #
# © 2010 Code24 BV #
# #
# Author : Alessandro Torrisi #
# Company : Code24 BV, The Netherlands #
# Date : July 31, 2010 #
# version : 1.0 #
# License : Creative Commons CC-BY license #
# Website : http://www.php-benchmark-script.com #
# #
##########################################################################
*/
function test_Math($count = 140000) {
$time_start = microtime(true);
$mathFunctions = array("abs", "acos", "asin", "atan", "bindec", "floor", "exp", "sin", "tan", "is_finite", "is_nan", "sqrt");
foreach ($mathFunctions as $key => $function) {
if (!function_exists($function)) unset($mathFunctions[$key]);
}
for ($i=0; $i < $count; $i++) {
foreach ($mathFunctions as $function) {
$r = call_user_func_array($function, array($i));
}
}
return number_format(microtime(true) - $time_start, 3);
}
function test_StringManipulation($count = 130000) {
$time_start = microtime(true);
$stringFunctions = array("addslashes", "chunk_split", "metaphone", "strip_tags", "md5", "sha1", "strtoupper", "strtolower", "strrev", "strlen", "soundex", "ord");
foreach ($stringFunctions as $key => $function) {
if (!function_exists($function)) unset($stringFunctions[$key]);
}
$string = "the quick brown fox jumps over the lazy dog";
for ($i=0; $i < $count; $i++) {
foreach ($stringFunctions as $function) {
$r = call_user_func_array($function, array($string));
}
}
return number_format(microtime(true) - $time_start, 3);
}
function test_Loops($count = 19000000) {
$time_start = microtime(true);
for($i = 0; $i < $count; ++$i);
$i = 0; while($i < $count) ++$i;
return number_format(microtime(true) - $time_start, 3);
}
function test_IfElse($count = 9000000) {
$time_start = microtime(true);
for ($i=0; $i < $count; $i++) {
if ($i == -1) {
} elseif ($i == -2) {
} else if ($i == -3) {
}
}
return number_format(microtime(true) - $time_start, 3);
}
$total = 0;
$functions = get_defined_functions();
$line = str_pad("-",38,"-");
foreach ($functions['user'] as $user) {
if (preg_match('/^test_/', $user)) {
$total += $result = $user();
echo str_pad($user, 25) . " : " . $result ." sec.\n";
}
}
echo str_pad("-", 38, "-") . "\n" . str_pad("Total time:", 25) . " : " . $total ." sec.</pre>";
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.1.0 0.007 1.057 23.06 7.0.14 0.007 1.173 22.82 5.4.36 0.003 2.477 19.94 5.4.34 0.007 2.470 19.90 5.4.24 0.213 2.283 20.19 5.4.23 0.217 2.280 20.14 5.4.22 0.240 2.260 19.94 5.4.21 0.007 2.413 20.07 5.4.20 0.037 2.397 19.83 5.4.19 0.217 2.280 19.81 5.4.18 0.200 2.297 20.43 5.4.17 0.020 2.377 20.06 5.4.16 0.137 2.363 20.17 5.4.15 0.023 2.390 19.69 5.4.14 0.037 2.460 17.44 5.4.13 0.023 2.343 17.18 5.4.12 0.027 2.470 17.41 5.4.11 0.010 2.487 17.59 5.4.10 0.040 2.460 17.64 5.4.9 0.020 2.410 17.33 5.4.8 0.013 2.483 17.46 5.4.7 0.020 2.460 17.39 5.4.6 0.003 2.433 17.34 5.4.5 0.023 2.460 17.36 5.4.4 0.013 2.440 17.31 5.4.3 0.010 2.487 17.55 5.4.2 0.060 2.440 17.52 5.4.1 0.027 2.417 17.09 5.4.0 0.017 2.403 16.86 5.3.28 0.037 2.460 15.46 5.3.27 0.043 2.453 15.61 5.3.26 0.047 2.450 15.64 5.3.25 0.040 2.457 15.47 5.3.24 0.017 2.377 15.36 5.3.23 0.027 2.380 15.48 5.3.22 0.017 2.417 15.31 5.3.21 0.010 2.377 15.45 5.3.20 0.020 2.387 15.32 5.3.19 0.033 2.463 15.59 5.3.18 0.040 2.457 15.46 5.3.17 0.040 2.457 15.42 5.3.16 0.023 2.443 15.34 5.3.15 0.020 2.433 15.44 5.3.14 0.013 2.483 15.41 5.3.13 0.010 2.487 15.40 5.3.12 0.027 2.470 15.40 5.3.11 0.020 2.430 15.39 5.3.10 0.023 2.473 14.87 5.3.9 0.033 2.463 14.89 5.3.8 0.007 2.450 14.69 5.3.7 0.020 2.393 14.83 5.3.6 0.033 2.310 14.68 5.3.5 0.023 2.433 14.65 5.3.4 0.010 2.457 14.63 5.3.3 0.063 2.433 14.76 5.3.2 0.037 2.460 14.54 5.3.1 0.047 2.453 14.56 5.3.0 0.027 2.470 14.48
preferences:dark mode live preview
30.23 ms | 400 KiB | 5 Q