3v4l.org

run code in 300+ PHP versions simultaneously
<?php $classmap1 = array(); for ($i=1; $i<=10000; $i++) { $classmap1['a'.$i] = $i+1; } $classmap2 = array(); for ($i=1; $i<=10000; $i++) { $classmap2['b'.$i] = $i+1; } $startTimeMerge = microtime(true); $map = array_merge($classmap1, $classmap2); $endTimeMerge = microtime(true); $startTimeForeach = microtime(true); foreach ($classmap2 as $k => $v) { $classmap1[$k] = $v; } $endTimeForeach = microtime(true); function amerge(array $a, array $b) { foreach ($b as $key => $value) { if (array_key_exists($key, $a)) { if (is_int($key)) { $a[] = $value; } elseif (is_array($value) && is_array($a[$key])) { $a[$key] = static::merge($a[$key], $value); } else { $a[$key] = $value; } } else { $a[$key] = $value; } } return $a; } $startTimeFunc = microtime(true); amerge($classmap1, $classmap2); $endTimeFunc = microtime(true); echo "Merging took " . (($endTimeMerge - $startTimeMerge)*1000) ." microseconds<br />\n"; echo "Foreach took " . (($endTimeForeach - $startTimeForeach)*1000) ." microseconds<br />\n"; echo "Func took " . (($endTimeFunc - $startTimeFunc)*1000) ." microseconds<br />\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)
5.6.250.0070.07330.07
5.6.240.0100.10029.86
5.6.230.0200.09029.79
5.6.220.0100.08029.95
5.6.210.0130.06730.06
5.6.200.0170.06030.39
5.6.190.0130.09030.23
5.6.180.0200.09330.24
5.6.170.0170.07730.40
5.6.160.0130.07030.23
5.6.150.0100.08030.22
5.6.140.0030.10330.22
5.6.130.0170.10030.30
5.6.120.0070.06330.34
5.6.110.0170.10030.39
5.6.100.0130.09730.45
5.6.90.0100.07330.29
5.6.80.0170.09329.63
5.6.70.0170.07329.62
5.6.60.0030.10329.61
5.6.50.0130.10029.71
5.6.40.0200.09329.60
5.6.30.0170.07729.70
5.6.20.0100.07329.66
5.6.10.0230.07729.55
5.6.00.0130.09729.68
5.5.380.0100.10329.85
5.5.370.0130.09029.68
5.5.360.0100.05329.63
5.5.350.0130.05729.63
5.5.340.0100.05330.11
5.5.330.0270.09030.10
5.5.320.0100.09330.19
5.5.310.0130.05730.09
5.5.300.0100.09730.05
5.5.290.0130.09730.19
5.5.280.0030.09730.16
5.5.270.0130.10330.15
5.5.260.0130.10330.18
5.5.250.0170.10029.89
5.5.240.0030.07029.56
5.5.230.0130.08329.55
5.5.220.0130.07029.55
5.5.210.0130.09029.44
5.5.200.0270.08329.40
5.5.190.0070.10729.43
5.5.180.0100.10029.54
5.5.160.0070.05029.40
5.5.150.0130.06029.52
5.5.140.0130.09729.51
5.5.130.0100.09029.52
5.5.120.0100.09329.39
5.5.110.0070.07729.54
5.5.100.0100.08029.37
5.5.90.0100.09029.41
5.5.80.0230.08329.36
5.5.70.0200.07029.34
5.5.60.0170.08029.41
5.5.50.0070.08329.25
5.5.40.0100.10329.14
5.5.30.0100.08729.11
5.5.20.0070.05729.14
5.5.10.0070.09029.23
5.5.00.0100.08729.20
5.4.450.0170.09728.43
5.4.440.0230.08728.39
5.4.430.0170.06028.25
5.4.420.0200.09328.48
5.4.410.0130.04728.25
5.4.400.0200.09728.16
5.4.390.0070.10027.91
5.4.380.0200.08328.15
5.4.370.0100.09327.94
5.4.360.0230.08728.07
5.4.350.0070.09328.07
5.4.340.0100.06328.15
5.4.320.0200.10028.21
5.4.310.0130.08027.88
5.4.300.0170.09328.05
5.4.290.0130.09028.05
5.4.280.0070.05328.21
5.4.270.0100.07727.99
5.4.260.0130.09328.09
5.4.250.0070.09727.93
5.4.240.0070.06728.07
5.4.230.0170.06328.24
5.4.220.0200.07328.05
5.4.210.0000.05728.06
5.4.200.0070.07028.02
5.4.190.0100.09728.05
5.4.180.0100.10028.14
5.4.170.0030.10728.04
5.4.160.0130.11027.87
5.4.150.0070.09727.92
5.4.140.0130.09325.36
5.4.130.0170.09325.48
5.4.120.0130.07325.50
5.4.110.0100.04725.50
5.4.100.0130.04725.46
5.4.90.0070.05025.53
5.4.80.0030.04325.48
5.4.70.0000.05725.40
5.4.60.0070.05325.45
5.4.50.0130.04325.55
5.4.40.0030.05325.41
5.4.30.0070.04725.38
5.4.20.0130.07025.43
5.4.10.0100.10025.33
5.4.00.0130.06024.90
5.3.290.0170.08023.77
5.3.280.0070.06323.79
5.3.270.0100.09723.80
5.3.260.0100.09723.81
5.3.250.0070.09723.71
5.3.240.0030.11023.76
5.3.230.0130.05723.73
5.3.220.0100.05023.77
5.3.210.0030.06023.66
5.3.200.0100.06323.72
5.3.190.0030.05723.63
5.3.180.0030.06023.66
5.3.170.0030.04723.65
5.3.160.0070.06023.83
5.3.150.0030.05723.63
5.3.140.0100.07323.75
5.3.130.0070.04323.75
5.3.120.0070.05323.60
5.3.110.0100.10323.64
5.3.100.0130.05723.08
5.3.90.0100.04723.25
5.3.80.0130.05322.98
5.3.70.0030.05323.09
5.3.60.0100.04723.12
5.3.50.0100.06322.98
5.3.40.0030.05322.98
5.3.30.0100.07023.34
5.3.20.0000.06022.73
5.3.10.0070.05322.75
5.3.00.0070.05022.46
5.2.170.0000.04312.37
5.2.160.0000.03012.37
5.2.150.0000.03012.37
5.2.140.0030.02712.37
5.2.130.0000.03012.37
5.2.120.0030.03712.37
5.2.110.0030.02712.37
5.2.100.0070.02312.37
5.2.90.0030.02712.37
5.2.80.0070.02312.37
5.2.70.0030.04012.37
5.2.60.0000.03312.37
5.2.50.0070.02312.37
5.2.40.0000.03012.37
5.2.30.0030.02712.37
5.2.20.0000.03312.37
5.2.10.0000.03012.37
5.2.00.0000.04312.37
5.1.60.0030.02712.37
5.1.50.0030.02312.37
5.1.40.0030.02312.37
5.1.30.0000.02712.37
5.1.20.0070.02712.37
5.1.10.0000.02312.37
5.1.00.0000.02712.37
5.0.50.0030.02012.37
5.0.40.0000.02012.37
5.0.30.0000.05012.37
5.0.20.0100.01712.37
5.0.10.0030.01712.37
5.0.00.0000.03312.37
4.4.90.0000.01712.37
4.4.80.0000.01712.37
4.4.70.0000.01712.37
4.4.60.0030.01312.37
4.4.50.0030.01312.37
4.4.40.0000.02312.37
4.4.30.0030.01012.37
4.4.20.0000.01712.37
4.4.10.0070.01012.37
4.4.00.0030.02312.37
4.3.110.0000.02312.37
4.3.100.0030.01312.37
4.3.90.0000.01312.37
4.3.80.0000.02712.37
4.3.70.0070.02712.37
4.3.60.0070.03012.37
4.3.50.0000.03312.37
4.3.40.0030.04312.37
4.3.30.0000.03012.37
4.3.20.0000.03712.37
4.3.10.0000.03312.37
4.3.00.0000.03712.37

preferences:
160.23 ms | 1398 KiB | 7 Q