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, $performance = false) { foreach ($b as $key => $value) { if ($performance == false || 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, true); $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.210.0100.10330.03
5.6.200.0130.09027.47
5.6.190.0100.11029.64
5.6.180.0300.05729.75
5.6.170.0270.10029.68
5.6.160.0130.04729.59
5.6.150.0070.05327.42
5.6.140.0030.08327.51
5.6.130.0130.09327.27
5.6.120.0070.05330.39
5.6.110.0200.09330.30
5.6.100.0030.08330.39
5.6.90.0070.09030.26
5.6.80.0170.06029.76
5.6.70.0300.09329.64
5.5.350.0300.10029.78
5.5.340.0100.11027.23
5.5.330.0030.07329.55
5.5.320.0230.08729.48
5.5.310.0430.07329.44
5.5.300.0070.10327.25
5.5.290.0100.04727.18
5.5.280.0230.09330.04
5.5.270.0130.09030.02
5.5.260.0100.08030.06
5.5.250.0070.05029.88
5.5.240.0200.08329.32
5.4.450.0030.09028.35
5.4.440.0070.09728.25
5.4.430.0130.08328.18
5.4.420.0070.08728.45
5.4.410.0100.05328.30
5.4.400.0030.08728.13
5.4.390.0070.05327.92
5.4.380.0200.06728.27
5.4.370.0100.05728.16
5.4.360.0100.11028.28
5.4.350.0130.08328.04
5.4.340.0100.10328.28
5.4.320.0070.05728.19
5.4.310.0230.05327.92
5.4.300.0100.09328.18
5.4.290.0200.09028.00
5.4.280.0070.09328.28
5.4.270.0170.06728.16
5.4.260.0130.09727.92
5.4.250.0230.08328.10
5.4.240.0030.06028.15
5.4.230.0130.08028.37
5.4.220.0070.06028.27
5.4.210.0130.09727.90
5.4.200.0100.10328.14
5.4.190.0070.09727.95
5.4.180.0100.05328.08
5.4.170.0070.10328.17
5.4.160.0130.05728.08
5.4.150.0200.07328.11
5.4.140.0200.09025.51
5.4.130.0070.10325.41
5.4.120.0130.10025.47
5.4.110.0070.10325.51
5.4.100.0030.07325.38
5.4.90.0100.09725.64
5.4.80.0130.09025.57
5.4.70.0130.08725.52
5.4.60.0070.07325.55
5.4.50.0070.09325.55
5.4.40.0130.10025.53
5.4.30.0130.09025.45
5.4.20.0230.05725.59
5.4.10.0070.07325.58
5.4.00.0130.09024.90
5.3.290.0100.10323.77
5.3.280.0100.06723.86
5.3.270.0230.09723.78
5.3.260.0130.09323.74
5.3.250.0100.10023.64
5.3.240.0070.07023.73
5.3.230.0100.08723.77
5.3.220.0170.08323.70
5.3.210.0070.08023.77
5.3.200.0170.09323.84
5.3.190.0130.09723.84
5.3.180.0070.10323.74
5.3.170.0130.10023.67
5.3.160.0070.07323.72
5.3.150.0130.10023.60
5.3.140.0200.04723.59
5.3.130.0100.09723.69
5.3.120.0230.06323.69
5.3.110.0130.09323.69
5.3.100.0170.09723.17
5.3.90.0070.10023.02
5.3.80.0030.08322.98
5.3.70.0070.08723.13
5.3.60.0200.05723.11
5.3.50.0070.05323.05
5.3.40.0100.08023.02
5.3.30.0070.05322.95
5.3.20.0000.06322.77
5.3.10.0100.09022.97
5.3.00.0100.08022.47
5.2.170.0100.02711.20
5.2.160.0200.04011.21
5.2.150.0070.03311.11
5.2.140.0070.03311.18
5.2.130.0100.05311.13
5.2.120.0100.05711.03
5.2.110.0100.06311.07
5.2.100.0000.03311.11
5.2.90.0030.02711.12
5.2.80.0070.03311.25
5.2.70.0030.03011.12
5.2.60.0070.04011.22
5.2.50.0030.03311.08
5.2.40.0000.03011.02
5.2.30.0070.02311.13
5.2.20.0000.03010.96
5.2.10.0000.03010.82
5.2.00.0070.02310.73
5.1.60.0000.02310.07
5.1.50.0030.02310.02
5.1.40.0130.0179.99
5.1.30.0070.02010.51
5.1.20.0000.02710.36
5.1.10.0070.02010.07
5.1.00.0030.0239.98
5.0.50.0030.0278.53
5.0.40.0000.0208.39
5.0.30.0000.0308.25
5.0.20.0030.0178.18
5.0.10.0000.0238.23
5.0.00.0000.0308.22
4.4.90.0000.0177.58
4.4.80.0030.0137.58
4.4.70.0000.0177.58
4.4.60.0030.0137.58
4.4.50.0030.0137.58
4.4.40.0000.0237.58
4.4.30.0000.0177.58
4.4.20.0030.0137.58
4.4.10.0030.0137.58
4.4.00.0000.0237.58
4.3.110.0000.0137.58
4.3.100.0030.0137.58
4.3.90.0030.0137.58
4.3.80.0000.0237.58
4.3.70.0030.0137.58
4.3.60.0000.0137.58
4.3.50.0070.0077.58
4.3.40.0000.0277.58
4.3.30.0030.0137.58
4.3.20.0030.0137.58
4.3.10.0000.0137.58
4.3.00.0000.0177.58

preferences:
143.16 ms | 1394 KiB | 7 Q