3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('ARRAY_SIZE', 512); define('RUNS', 1e4); function benchmark($function, $desc) { $total_time = 0; for($i = 0; $i < RUNS; $i++) { $total_time += $function(); } echo sprintf('%dx %s took %.5f seconds' . PHP_EOL, RUNS, $desc, $total_time); } benchmark(function() { $r = range(0, ARRAY_SIZE); $start = microtime(true); foreach ($r as $k => $v) { for($i = 0; $i $v) { $r[$k] => $v * $v; } return microtime(true) - $start; }, 'foreach'); benchmark(function() { $r = range(0, ARRAY_SIZE); $start = microtime(true); $r = array_map(function($each) { return $each * $eacha; }, $r); return microtime(true) - $start; }, 'array_map');

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)
5.4.290.0170.04319.31
5.4.280.0270.04319.10
5.4.270.0300.03718.95
5.4.260.0230.05719.22
5.4.250.0270.04719.23
5.4.240.0330.05718.98
5.4.230.0270.04318.81
5.4.220.0330.07019.08
5.4.210.0400.06318.87
5.4.200.0370.05719.15
5.4.190.0230.05319.14
5.4.180.0230.05319.17
5.4.170.0230.06319.05
5.4.160.0230.04319.07
5.4.150.0170.04319.22
5.4.140.0270.04716.38
5.4.130.0300.03716.54
5.4.120.0200.04716.56
5.4.110.0370.06016.31
5.4.100.0300.06316.45
5.4.90.0270.06716.50
5.4.80.0270.07016.59
5.4.70.0330.05716.29
5.4.60.0300.02716.38
5.4.50.0330.03716.33
5.4.40.0270.07016.48
5.4.30.0470.04316.51
5.4.20.0270.04016.53
5.4.10.0300.06716.51
5.4.00.0430.05715.75
5.3.280.0200.04314.71
5.3.270.0300.06714.66
5.3.260.0330.05014.69
5.3.250.0230.04314.68
5.3.240.0300.07014.53
5.3.230.0270.06714.50
5.3.220.0230.04714.47
5.3.210.0270.05014.70
5.3.200.0330.06014.47
5.3.190.0270.05014.69
5.3.180.0270.04014.57
5.3.170.0300.05714.54
5.3.160.0400.06314.62
5.3.150.0300.07014.48
5.3.140.0300.06714.46
5.3.130.0370.06714.63
5.3.120.0330.06714.45
5.3.110.0270.06014.46
5.3.100.0200.04013.95
5.3.90.0230.03714.11
5.3.80.0270.07013.95
5.3.70.0230.06714.03
5.3.60.0300.07014.13
5.3.50.0270.04714.07
5.3.40.0230.06013.91
5.3.30.0370.05313.91
5.3.20.0230.06713.91
5.3.10.0330.05713.91
5.3.00.0300.05713.91
5.2.170.0200.04013.91
5.2.160.0170.03713.91
5.2.150.0200.07013.91
5.2.140.0170.05013.91
5.2.130.0170.03713.91
5.2.120.0230.04013.91
5.2.110.0270.03013.91
5.2.100.0170.05013.91
5.2.90.0230.03313.91
5.2.80.0230.05713.91
5.2.70.0270.05013.91
5.2.60.0270.06013.91
5.2.50.0300.04313.91
5.2.40.0200.03713.91
5.2.30.0130.06313.91
5.2.20.0200.05713.91
5.2.10.0230.05313.91
5.2.00.0270.05013.91
5.1.60.0200.04713.91
5.1.50.0200.05013.91
5.1.40.0230.03313.91
5.1.30.0270.03313.91
5.1.20.0170.05313.91
5.1.10.0300.04313.91
5.1.00.0270.02713.91
5.0.50.0230.03713.91
5.0.40.0130.03713.91
5.0.30.0030.03713.91
5.0.20.0070.03313.91
5.0.10.0100.04313.91
5.0.00.0130.04713.91
4.4.90.0170.02713.91
4.4.80.0170.02713.91
4.4.70.0100.03013.91
4.4.60.0070.03313.91
4.4.50.0070.03313.91
4.4.40.0100.03713.91
4.4.30.0100.02013.91
4.4.20.0070.04013.91
4.4.10.0130.03013.91
4.4.00.0070.04313.91
4.3.110.0170.02013.91
4.3.100.0130.03013.91
4.3.90.0170.01713.91
4.3.80.0100.05313.91
4.3.70.0100.03713.91
4.3.60.0070.03313.91
4.3.50.0200.02313.91
4.3.40.0300.03013.91
4.3.30.0070.03313.91
4.3.20.0070.03713.91
4.3.10.0000.03313.91
4.3.00.0030.04013.91

preferences:
143.14 ms | 1394 KiB | 7 Q