3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* ########################################################################## # PHP Benchmark Performance Script # # <A9> 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 # # # ########################################################################## */ set_time_limit(0); function get_microtime() { $time = microtime(true); if (is_string($time)) { list($f, $i) = explode(" ", $time); $time = intval($i) + floatval($f); } return $time; } function test_Math($count = 140000) { $time_start = get_microtime(); $mathFunctions = array("abs", "acos", "asin", "atan", "bindec", "floor", "exp", "sin", "tan", "pi", "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(get_microtime() - $time_start, 3); } function test_StringManipulation($count = 130000) { $time_start = get_microtime(); $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(get_microtime() - $time_start, 3); } function test_Loops($count = 19000000) { $time_start = get_microtime(); for($i = 0; $i < $count; ++$i); $i = 0; while($i++ < $count); return number_format(get_microtime() - $time_start, 3); } function test_IfElse($count = 9000000) { $time_start = get_microtime(); for ($i=0; $i < $count; $i++) { if ($i == -1) { } elseif ($i == -2) { } else if ($i == -3) { } } return number_format(get_microtime() - $time_start, 3); } $total = 0; $functions = get_defined_functions(); $line = str_pad("-",38,"-"); echo "<pre>\n$line\n|".str_pad("PHP BENCHMARK SCRIPT",36," ",STR_PAD_BOTH)."|\n$line\nStart : ".date("Y-m-d H:i:s")."\nServer : ".php_uname()."\nPHP version : ".PHP_VERSION."\nPlatform : ".PHP_OS. "\n$line\n"; foreach ($functions['user'] as $user) { if (preg_match('/^test_/', $user)) { $result = $user(); $total += $result; echo str_pad($user, 25) . " : " . $result ." sec.\n"; } } echo str_pad("-", 38, "-") . "\n" . str_pad("Total time:", 25) . " : " . $total ." sec.\n</pre>\n";

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.3.120.0031.10816.00
7.3.110.0071.05315.89
7.3.100.0071.06616.01
7.3.90.0101.05816.01
7.3.80.0031.05716.29
7.3.70.0031.06215.97
7.3.60.0071.07815.96
7.3.50.0031.07815.89
7.3.40.0071.19316.04
7.3.30.0101.04615.67
7.3.20.0071.05417.65
7.3.10.0081.13217.40
7.3.00.0081.16117.52
7.2.240.0031.25616.06
7.2.230.0071.18416.14
7.2.220.0101.17216.22
7.2.210.0071.17316.08
7.2.200.0031.18315.98
7.2.190.0071.20416.09
7.2.180.0031.16216.10
7.2.170.0071.13916.05
7.2.160.0001.14516.23
7.2.150.0031.31617.88
7.2.140.0031.17118.04
7.2.130.0051.28917.89
7.2.120.0171.21317.61
7.2.110.0051.23817.59
7.2.100.0081.29217.66
7.2.90.0121.28917.77
7.2.80.0021.24217.71
7.2.70.0071.27117.68
7.2.60.0041.26617.81
7.2.50.0081.29817.86
7.2.40.0111.30817.76
7.2.30.0081.25217.60
7.2.20.0031.35117.89
7.2.10.0081.34217.64
7.2.00.0051.17518.66
7.1.330.0032.14216.63
7.1.320.0031.98116.67
7.1.310.0131.93017.04
7.1.300.0071.94016.63
7.1.290.0101.94616.76
7.1.280.0032.10416.66
7.1.270.0101.94316.56
7.1.260.0031.96216.70
7.1.250.0082.03216.76
7.1.70.0000.98118.37
7.1.60.0070.99619.32
7.1.50.0170.97718.01
7.1.00.0001.06723.11
7.0.200.0071.15417.73
7.0.140.0031.20322.79
7.0.90.0500.99720.72
7.0.80.0070.94020.62
7.0.70.0401.10020.72
7.0.60.0371.09020.68
7.0.50.0171.04021.00
7.0.40.0101.08720.76
7.0.30.0100.93720.74
7.0.20.0201.04020.77
7.0.10.0171.02720.68
7.0.00.0100.86320.68
5.6.280.0002.50022.09
5.6.240.0102.49021.81
5.6.230.2202.27721.70
5.6.220.0002.46721.54
5.6.210.0102.49021.77
5.6.200.0072.49322.25
5.6.190.1772.32322.27
5.6.180.0102.49022.22
5.6.170.0132.46722.19
5.6.160.0002.50022.14
5.6.150.0032.42022.29
5.6.140.0002.41322.19
5.6.130.2172.28322.10
5.6.120.0032.49722.20
5.6.110.0032.49722.08
5.6.100.0072.47722.15
5.6.90.0172.48322.13
5.6.80.0072.49321.61
5.6.70.0132.48721.59
5.6.60.0102.49021.61
5.6.50.0102.49021.61
5.6.40.0072.41321.50
5.6.30.0172.48321.49
5.6.20.0172.48321.51
5.6.10.0102.49021.46
5.6.00.0072.49321.54
5.5.380.0032.49721.64
5.5.370.0002.49021.20
5.5.360.0072.49321.63
5.5.350.0072.45321.39
5.5.340.0132.42022.00
5.5.330.0002.50021.89
5.5.320.0332.39721.85
5.5.310.0072.49321.92
5.5.300.0132.46721.95
5.5.290.0302.41321.76
5.5.280.0172.43321.62
5.5.270.0232.22321.72
5.5.260.0032.49722.03
5.5.250.0331.87321.64
5.5.240.0102.49021.34
5.5.230.0002.36721.40
5.5.220.0032.49721.42
5.5.210.0102.49021.40
5.5.200.0072.49321.37
5.5.190.0072.49321.31
5.5.180.0032.49721.37
5.5.160.0102.49021.41
5.5.150.0032.42021.35
5.5.140.0032.49721.37
5.5.130.0302.41321.18
5.5.120.0272.39021.09
5.5.110.0202.19321.20
5.5.100.0271.90021.00
5.5.90.0072.49321.26
5.5.80.0132.48721.21
5.5.70.0072.49321.21
5.5.60.0371.94721.23
5.5.50.0172.40721.27
5.5.40.0372.33720.90
5.5.30.0002.47021.23
5.5.20.0102.41721.19
5.5.10.0032.49721.23
5.5.00.0032.49721.13
5.4.450.0172.48320.55
5.4.440.0102.44720.19
5.4.430.0202.06320.14
5.4.420.0002.50020.37
5.4.410.0131.94719.99
5.4.400.0201.92020.08
5.4.390.0072.49019.79
5.4.380.0102.49020.20
5.4.370.0072.49320.05
5.4.360.0302.13319.93
5.4.350.0372.36319.88
5.4.340.0272.35319.92
5.4.320.0172.48320.04
5.4.310.0032.49720.21
5.4.300.0202.36319.91
5.4.290.0032.49720.21
5.4.280.0202.38319.84
5.4.270.0132.43719.84
5.4.260.0002.50020.08
5.4.250.0132.05019.95
5.4.240.0132.48720.05
5.4.230.0271.91719.96
5.4.220.0302.21019.95
5.4.210.0032.49720.05
5.4.200.0272.39019.92
5.4.190.0002.48719.99
5.4.180.0232.35719.88
5.4.170.0072.49320.05
5.4.160.0032.49720.13
5.4.150.0102.44019.79
5.4.140.0072.49317.49
5.4.130.0002.50017.38
5.4.120.0072.49317.42
5.4.110.0202.42317.33
5.4.100.0032.39717.29
5.4.90.0072.49317.53
5.4.80.0072.44017.29
5.4.70.0072.49317.49
5.4.60.0131.91017.38
5.4.50.0102.49017.51
5.4.40.0202.14717.31
5.4.30.0072.44317.37
5.4.20.0132.45317.36
5.4.10.0102.49017.32
5.4.00.0032.48016.64
5.3.290.0102.49015.68
5.3.280.0002.50015.52
5.3.270.0132.48715.57
5.3.260.0032.49715.60
5.3.250.0072.45715.32
5.3.240.0172.40715.33
5.3.230.0032.49715.54
5.3.220.0072.49315.50
5.3.210.0102.49015.46
5.3.200.0072.49315.48
5.3.190.0072.49315.49
5.3.180.0302.14315.41
5.3.170.0132.10015.34
5.3.160.0101.94315.31
5.3.150.0032.49715.49
5.3.140.0102.49015.48
5.3.130.0102.39315.30
5.3.120.0302.41015.31
5.3.110.0102.41015.31
5.3.100.0202.48014.93
5.3.90.0132.48714.94
5.3.80.0202.48015.02
5.3.70.0202.40314.87
5.3.60.0002.50014.92
5.3.50.0072.49314.96
5.3.40.0072.43014.71
5.3.30.0232.39714.66
5.3.20.0132.48714.58
5.3.10.0102.17314.39
5.3.00.0201.96714.53

preferences:
34.41 ms | 401 KiB | 5 Q