3v4l.org

run code in 300+ PHP versions simultaneously
<?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>";

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).

VersionSystem time (s)User time (s)Memory (MiB)
7.1.00.0071.05723.06
7.0.140.0071.17322.82
5.4.360.0032.47719.94
5.4.340.0072.47019.90
5.4.240.2132.28320.19
5.4.230.2172.28020.14
5.4.220.2402.26019.94
5.4.210.0072.41320.07
5.4.200.0372.39719.83
5.4.190.2172.28019.81
5.4.180.2002.29720.43
5.4.170.0202.37720.06
5.4.160.1372.36320.17
5.4.150.0232.39019.69
5.4.140.0372.46017.44
5.4.130.0232.34317.18
5.4.120.0272.47017.41
5.4.110.0102.48717.59
5.4.100.0402.46017.64
5.4.90.0202.41017.33
5.4.80.0132.48317.46
5.4.70.0202.46017.39
5.4.60.0032.43317.34
5.4.50.0232.46017.36
5.4.40.0132.44017.31
5.4.30.0102.48717.55
5.4.20.0602.44017.52
5.4.10.0272.41717.09
5.4.00.0172.40316.86
5.3.280.0372.46015.46
5.3.270.0432.45315.61
5.3.260.0472.45015.64
5.3.250.0402.45715.47
5.3.240.0172.37715.36
5.3.230.0272.38015.48
5.3.220.0172.41715.31
5.3.210.0102.37715.45
5.3.200.0202.38715.32
5.3.190.0332.46315.59
5.3.180.0402.45715.46
5.3.170.0402.45715.42
5.3.160.0232.44315.34
5.3.150.0202.43315.44
5.3.140.0132.48315.41
5.3.130.0102.48715.40
5.3.120.0272.47015.40
5.3.110.0202.43015.39
5.3.100.0232.47314.87
5.3.90.0332.46314.89
5.3.80.0072.45014.69
5.3.70.0202.39314.83
5.3.60.0332.31014.68
5.3.50.0232.43314.65
5.3.40.0102.45714.63
5.3.30.0632.43314.76
5.3.20.0372.46014.54
5.3.10.0472.45314.56
5.3.00.0272.47014.48

preferences:
30.23 ms | 400 KiB | 5 Q