3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mapCallback1($callback, $array){ $output = []; array_map(function($value) use ($callback, &$output) { $callback($value, function($value) use (&$output) { $output[] = $value; }); }, $array); return $output; } function mapCallback2($callback, $array){ $output = []; $push = function ($value) use (&$output) { $output[] = $value; }; foreach ($array as $value) { $callback($value, $push); } return $output; } $square = function ($x, $push) { $push($x * $x); }; $t = microtime(1); for ($i = 100000; $i--;) mapCallback1($square, [1, 2, 3]); echo 1000 * (microtime(1) - $t) . PHP_EOL; $t = microtime(1); for ($i = 100000; $i--;) mapCallback2($square, [1, 2, 3]); echo 1000 * (microtime(1) - $t) . PHP_EOL; var_dump(mapCallback1($square, [1, 2, 3])); var_dump(mapCallback2($square, [1, 2, 3]));

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.4.10.0000.35314.86
7.4.00.0130.25014.95
7.3.130.0070.36214.63
7.3.120.0030.34315.01
7.3.110.0070.29214.71
7.3.100.0070.21614.59
7.3.90.0000.24414.77
7.3.80.0070.32815.05
7.3.70.0000.29715.03
7.3.60.0100.21914.84
7.3.50.0030.30414.98
7.3.40.0000.28114.79
7.3.30.0030.23314.99
7.3.20.0100.21616.63
7.3.10.0080.24516.46
7.3.00.0080.26516.60
7.2.260.0100.40814.95
7.2.250.0030.40515.11
7.2.240.0030.33715.04
7.2.230.0030.40314.97
7.2.220.0100.34315.27
7.2.210.0000.35715.05
7.2.200.0100.30715.18
7.2.190.0070.36114.98
7.2.180.0000.30214.82
7.2.170.0030.36915.17
7.2.160.0000.35015.00
7.2.150.0000.26317.00
7.2.140.0030.26516.67
7.2.130.0050.32416.67
7.2.120.0070.32616.82
7.2.110.0130.33616.82
7.2.100.0070.28616.75
7.2.90.0080.35416.91
7.2.80.0030.31216.91
7.2.70.0100.31916.82
7.2.60.0070.34316.85
7.2.50.0080.31616.87
7.2.40.0030.36716.83
7.2.30.0080.33317.02
7.2.20.0070.29917.07
7.2.10.0040.31516.65
7.2.00.0050.33716.92
7.1.330.0070.43816.00
7.1.320.0000.37315.71
7.1.310.0030.38415.64
7.1.300.0000.42915.75
7.1.290.0030.41115.81
7.1.280.0030.36815.51
7.1.270.0000.39915.59
7.1.260.0070.44315.99
7.1.250.0050.41215.64
7.1.240.0100.35915.88
7.1.230.0100.40315.61
7.1.220.0030.50515.84
7.1.210.0030.38715.81
7.1.200.0070.40415.97
7.1.190.0000.48315.98
7.1.180.0030.45515.97
7.1.170.0030.33115.95
7.1.160.0070.41215.89
7.1.150.0030.43415.84
7.1.140.0070.45315.83
7.1.130.0070.46415.87
7.1.120.0130.37315.46
7.1.110.0070.33615.89
7.1.100.0130.35915.83
7.1.90.0030.41815.95
7.1.80.0110.49416.84
7.1.70.0060.43816.57
7.1.60.0080.39225.33
7.1.50.0100.45225.24
7.1.40.0140.48725.04
7.1.30.0180.41925.12
7.1.20.0100.46125.19
7.1.10.0100.49116.12
7.1.00.0000.45916.26
7.0.330.0100.49915.48
7.0.320.0070.45715.50
7.0.310.0070.54615.34
7.0.300.0030.49115.53
7.0.290.0070.53315.18
7.0.280.0030.45115.43
7.0.270.0000.59715.49
7.0.260.0030.52215.57
7.0.250.0030.59715.52
7.0.240.0070.52815.59
7.0.230.0100.52015.54
7.0.220.0130.44415.38
7.0.210.0070.43015.56
7.0.200.0090.47216.16
7.0.190.0030.53816.23
7.0.180.0040.55615.90
7.0.170.0050.46415.74
7.0.160.0090.56515.83
7.0.150.0050.47015.82
7.0.140.0110.52315.81
7.0.130.0070.48215.89
7.0.120.0020.47215.97
7.0.110.0160.60716.05
7.0.100.0170.59315.92
7.0.90.0030.55416.00
7.0.80.0030.53915.87
7.0.70.0070.47315.97
7.0.60.0040.46915.79
7.0.50.0060.56315.96
7.0.40.0090.58715.06
7.0.30.0120.45915.06
7.0.20.0060.63514.97
7.0.10.0080.53314.96
7.0.00.0100.53414.93
5.6.400.0070.84214.34
5.6.390.0001.04614.70
5.6.380.0070.86914.25
5.6.370.0000.90314.48
5.6.360.0070.91014.76
5.6.350.0070.97414.29
5.6.340.0030.92014.73
5.6.330.0101.10714.37
5.6.320.0130.94314.78
5.6.310.0000.87814.36
5.6.300.0130.90914.39
5.6.290.0071.06114.42
5.6.280.0101.00514.41
5.6.270.0030.85414.65
5.6.260.0001.20214.18
5.6.250.0030.91514.63
5.6.240.0071.09314.67
5.6.230.0101.05214.29
5.6.220.0030.96614.23
5.6.210.0031.10014.56
5.6.200.0031.07714.39
5.6.190.0071.14514.34
5.6.180.0071.17214.41
5.6.170.0001.05614.42
5.6.160.0031.23314.57
5.6.150.0101.09314.27
5.6.140.0071.06114.51
5.6.130.0071.15714.66
5.6.120.0000.91214.44
5.6.110.0071.19514.31
5.6.100.0031.18914.73
5.6.90.0000.86414.57
5.6.80.0100.97814.48
5.6.70.0031.16914.29
5.6.60.0071.04714.45
5.6.50.0131.13914.31
5.6.40.0000.91114.27
5.6.30.0031.04114.46
5.6.20.0070.93614.38
5.6.10.0031.04914.18
5.6.00.0070.92414.36

preferences:
43.09 ms | 401 KiB | 5 Q