3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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>";
Output for 7.1.0
test_math : 0.222 sec. test_stringmanipulation : 0.320 sec. test_loops : 0.109 sec. test_ifelse : 0.367 sec. -------------------------------------- Total time: : 1.018 sec.</pre>
Output for 7.0.14
test_math : 0.113 sec. test_stringmanipulation : -0.325 sec. test_loops : -0.181 sec. test_ifelse : 1.495 sec. -------------------------------------- Total time: : 1.102 sec.</pre>
Output for 5.4.36
test_math : 0.690 sec. test_stringmanipulation : 0.750 sec. test_loops : 0.601 sec. test_ifelse : 0.383 sec. -------------------------------------- Total time: : 2.424 sec.</pre>
Output for 5.4.34
test_math : 0.690 sec. test_stringmanipulation : 0.752 sec. test_loops : 0.608 sec. test_ifelse : 0.384 sec. -------------------------------------- Total time: : 2.434 sec.</pre>
Output for 5.4.24
test_math : 0.692 sec. test_stringmanipulation : 0.761 sec. test_loops : 0.600 sec.
Process exited with code 137.
Output for 5.4.23
test_math : 0.699 sec. test_stringmanipulation : 0.764 sec. test_loops : 0.599 sec.
Process exited with code 137.
Output for 5.4.22
test_math : 0.704 sec. test_stringmanipulation : 0.751 sec. test_loops : 0.590 sec.
Process exited with code 137.
Output for 5.4.21
test_math : 1.256 sec.
Process exited with code 137.
Output for 5.4.20
test_math : 1.194 sec.
Process exited with code 137.
Output for 5.4.19
test_math : 0.775 sec. test_stringmanipulation : 0.768 sec. test_loops : 0.669 sec.
Process exited with code 137.
Output for 5.4.18
test_math : 0.700 sec. test_stringmanipulation : 0.755 sec. test_loops : 0.598 sec.
Process exited with code 137.
Output for 5.4.17
test_math : 1.433 sec.
Process exited with code 137.
Output for 5.4.16
test_math : 0.719 sec. test_stringmanipulation : 0.779 sec. test_loops : 0.594 sec.
Process exited with code 137.
Output for 5.4.15
test_math : 1.567 sec.
Process exited with code 137.
Output for 5.4.14
test_math : 0.714 sec. test_stringmanipulation : 0.781 sec. test_loops : 0.629 sec.
Process exited with code 137.
Output for 5.4.13
test_math : 1.556 sec.
Process exited with code 137.
Output for 5.4.12
test_math : 1.143 sec. test_stringmanipulation : 1.262 sec.
Process exited with code 137.
Output for 5.4.11
test_math : 0.723 sec. test_stringmanipulation : 0.787 sec. test_loops : 0.601 sec.
Process exited with code 137.
Output for 5.4.10
test_math : 0.698 sec. test_stringmanipulation : 0.774 sec. test_loops : 0.601 sec.
Process exited with code 137.
Output for 5.3.23, 5.4.9
test_math : 1.209 sec.
Process exited with code 137.
Output for 5.4.8
test_math : 0.786 sec. test_stringmanipulation : 0.760 sec. test_loops : 0.598 sec.
Process exited with code 137.
Output for 5.4.7
test_math : 1.051 sec. test_stringmanipulation : 1.201 sec.
Process exited with code 137.
Output for 5.4.6
test_math : 1.220 sec.
Process exited with code 137.
Output for 5.4.5
test_math : 0.685 sec. test_stringmanipulation : 0.753 sec. test_loops : 0.597 sec. test_ifelse : 0.383 sec. -------------------------------------- Total time: : 2.418 sec.</pre>
Output for 5.4.4
test_math : 1.527 sec.
Process exited with code 137.
Output for 5.4.3
test_math : 1.000 sec. test_stringmanipulation : 1.108 sec.
Process exited with code 137.
Output for 5.4.2
test_math : 0.738 sec. test_stringmanipulation : 0.751 sec. test_loops : 0.597 sec.
Process exited with code 137.
Output for 5.4.1
test_math : 1.426 sec.
Process exited with code 137.
Output for 5.4.0
test_math : 1.164 sec.
Process exited with code 137.
Output for 5.3.28
test_math : 0.752 sec. test_stringmanipulation : 0.798 sec. test_loops : 0.808 sec.
Process exited with code 137.
Output for 5.3.27
test_math : 0.788 sec. test_stringmanipulation : 0.860 sec.
Process exited with code 137.
Output for 5.3.26
test_math : 0.758 sec. test_stringmanipulation : 0.945 sec.
Process exited with code 137.
Output for 5.3.25
test_math : 0.821 sec. test_stringmanipulation : 1.024 sec.
Process exited with code 137.
Output for 5.3.24
test_math : 1.466 sec.
Process exited with code 137.
Output for 5.3.22
test_math : 1.314 sec.
Process exited with code 137.
Output for 5.3.21
test_math : 1.676 sec.
Process exited with code 137.
Output for 5.3.20
test_math : 1.477 sec.
Process exited with code 137.
Output for 5.3.19
test_math : 0.756 sec. test_stringmanipulation : 0.803 sec. test_loops : 0.817 sec.
Process exited with code 137.
Output for 5.3.18
test_math : 0.720 sec. test_stringmanipulation : 0.797 sec. test_loops : 0.812 sec.
Process exited with code 137.
Output for 5.3.17
test_math : 0.747 sec. test_stringmanipulation : 0.806 sec.
Process exited with code 137.
Output for 5.3.7, 5.3.16
test_math : 1.181 sec.
Process exited with code 137.
Output for 5.3.15
test_math : 1.291 sec.
Process exited with code 137.
Output for 5.3.14
test_math : 0.737 sec. test_stringmanipulation : 0.801 sec. test_loops : 0.826 sec.
Process exited with code 137.
Output for 5.3.13
test_math : 0.730 sec. test_stringmanipulation : 0.784 sec. test_loops : 0.818 sec.
Process exited with code 137.
Output for 5.3.12
test_math : 0.744 sec. test_stringmanipulation : 0.787 sec. test_loops : 0.819 sec.
Process exited with code 137.
Output for 5.3.11
test_math : 1.313 sec.
Process exited with code 137.
Output for 5.3.10
test_math : 0.731 sec. test_stringmanipulation : 0.792 sec. test_loops : 0.817 sec.
Process exited with code 137.
Output for 5.3.9
test_math : 0.713 sec. test_stringmanipulation : 0.783 sec. test_loops : 0.886 sec.
Process exited with code 137.
Output for 5.3.8
test_math : 1.142 sec.
Process exited with code 137.
Output for 5.3.6
test_math : 1.501 sec.
Process exited with code 137.
Output for 5.3.5
test_math : 1.338 sec.
Process exited with code 137.
Output for 5.3.4
test_math : 1.358 sec.
Process exited with code 137.
Output for 5.3.3
test_math : 0.756 sec. test_stringmanipulation : 0.792 sec.
Process exited with code 137.
Output for 5.3.2
test_math : 0.743 sec. test_stringmanipulation : 0.788 sec. test_loops : 0.853 sec.
Process exited with code 137.
Output for 5.3.1
test_math : 0.810 sec. test_stringmanipulation : 0.817 sec.
Process exited with code 137.
Output for 5.3.0
test_math : 1.083 sec. test_stringmanipulation : 1.239 sec.
Process exited with code 137.