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); $startTimeReplace = microtime(true); $map = array_replace($classmap1, $classmap2); $endTimeReplace = microtime(true); $startTimePlus = microtime(true); $map = $classmap1 + $classmap2; $endTimePlus = microtime(true); $startTimeForeach = microtime(true); foreach ($classmap2 as $k => $v) { $classmap1[$k] = $v; } $endTimeForeach = microtime(true); echo "array_merge - " . (($endTimeMerge - $startTimeMerge)*1000) ." microseconds<br />\n"; echo "array_replace - " . (($endTimeReplace - $startTimeReplace)*1000) ." microseconds<br />\n"; echo "array + array - " . (($endTimePlus - $startTimePlus)*1000) ." microseconds<br />\n"; echo "foreach - " . (($endTimeForeach - $startTimeForeach)*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)
8.0.20.0160.01321.52
8.0.10.0170.01321.56
8.0.00.0130.01621.46
7.4.150.0120.01620.94
7.4.140.0130.01620.76
7.4.130.0150.01520.93
7.4.120.0110.01820.95
7.4.110.0210.01120.93
7.4.100.0120.01621.05
7.4.90.0110.01920.99
7.4.80.0200.01221.07
7.4.70.0130.01620.99
7.4.60.0150.01520.93
7.4.50.0210.00721.05
7.4.40.0280.01220.82
7.4.30.0220.01920.54
7.4.20.0130.02820.95
7.4.10.0350.00621.17
7.4.00.0130.02020.97
7.3.270.0120.01821.07
7.3.260.0160.01220.72
7.3.250.0090.01920.87
7.3.240.0200.02020.95
7.3.230.0160.01220.97
7.3.220.0160.01321.17
7.3.210.0100.02020.88
7.3.200.0210.00920.63
7.3.190.0120.02521.01
7.3.180.0110.01820.85
7.3.170.0140.01720.80
7.3.160.0220.01620.64
7.3.150.0200.01420.69
7.3.140.0250.00920.80
7.3.130.0130.01921.05
7.3.120.0170.01920.92
7.3.110.0230.01320.65
7.3.100.0140.02120.80
7.3.90.0260.00720.77
7.3.80.0270.01220.78
7.3.70.0200.01020.76
7.3.60.0080.02420.63
7.3.50.0240.01320.83
7.3.40.0210.00920.66
7.3.30.0100.02520.73
7.3.20.0130.02020.97
7.3.10.0220.01120.86
7.3.00.0120.01820.89
7.2.340.0180.01121.13
7.2.330.0150.01521.23
7.2.320.0060.02221.08
7.2.310.0110.01821.12
7.2.300.0230.00621.06
7.2.290.0160.02221.14
7.2.280.0140.01821.20
7.2.270.0160.01620.99
7.2.260.0200.02220.88
7.2.250.0170.01720.96
7.2.240.0200.02020.57
7.2.230.0090.02420.96
7.2.220.0160.01321.04
7.2.210.0130.01620.95
7.2.200.0220.01420.90
7.2.190.0230.01621.03
7.2.180.0130.01720.92
7.2.170.0160.01320.91
7.2.160.0130.01620.97
7.2.150.0170.02321.01
7.2.140.0260.01521.20
7.2.130.0290.00620.89
7.2.120.0160.01320.85
7.2.110.0320.01020.70
7.2.100.0150.01521.00
7.2.90.0230.01720.97
7.2.80.0100.01920.69
7.2.70.0120.01821.03
7.2.60.0140.02520.96
7.2.50.0350.02121.06
7.2.40.0100.02020.95
7.2.30.0160.01621.00
7.2.20.0460.01020.94
7.2.10.0090.02220.89
7.2.00.0150.01423.08
7.1.330.0840.00919.35
7.1.320.0220.01319.46
7.1.310.0160.01619.58
7.1.300.0210.02219.39
7.1.290.0340.00719.37
7.1.280.0170.01319.35
7.1.270.0250.01619.15
7.1.260.0140.01719.27
7.1.250.0150.01819.39
7.1.240.0390.00319.18
7.1.230.0130.01719.28
7.1.220.0190.00919.15
7.1.210.0210.00919.32
7.1.200.0190.00919.29
7.1.190.0160.02219.40
7.1.180.0110.02619.40
7.1.170.0100.02019.26
7.1.160.0180.01219.39
7.1.150.0200.01419.27
7.1.140.0130.01819.15
7.1.130.0180.01419.29
7.1.120.0090.01919.15
7.1.110.0230.00619.39
7.1.100.0160.02419.23
7.1.90.0180.01519.38
7.1.80.0200.02019.18
7.1.70.0190.00621.26
7.1.60.0140.02221.26
7.1.50.0140.01721.08
7.1.40.0440.01118.89
7.1.30.0310.00618.93
7.1.20.0270.00919.19
7.1.10.0240.01218.83
7.1.00.0240.03523.57
7.0.330.0130.02919.13
7.0.320.0350.02519.06
7.0.310.0380.01619.05
7.0.300.0240.01718.91
7.0.290.0250.02519.03
7.0.280.0340.01518.93
7.0.270.0280.01419.04
7.0.260.0280.01419.06
7.0.250.0430.02519.05
7.0.240.0220.02219.01
7.0.230.0490.02419.05
7.0.220.0270.02719.02
7.0.210.0240.02118.90
7.0.200.0230.01120.82
7.0.190.0400.00418.86
7.0.180.0240.01819.09
7.0.170.0220.02218.93
7.0.160.0520.01519.15
7.0.150.0160.02619.02
7.0.140.0170.04423.55
7.0.130.0230.01919.20
7.0.120.0520.00818.99
7.0.110.0400.01918.93
7.0.100.0320.03021.41
7.0.90.0180.04821.31
7.0.80.0250.04921.30
7.0.70.0250.05121.28
7.0.60.0320.04921.32
7.0.50.0430.04021.49
7.0.40.0230.04919.52
7.0.30.0200.05419.43
7.0.20.0210.04719.57
7.0.10.0240.02519.52
7.0.00.0250.05419.53
5.6.400.0350.02423.38
5.6.390.0280.04223.20
5.6.380.0240.03823.37
5.6.370.0170.05022.93
5.6.360.0280.03522.87
5.6.350.0390.02323.44
5.6.340.0340.02423.36
5.6.330.0220.03423.36
5.6.320.0340.02423.35
5.6.310.0260.05123.34
5.6.300.0320.02823.26
5.6.290.0220.03823.36
5.6.280.0160.06325.78
5.6.270.0370.02923.35
5.6.260.0360.02223.32
5.6.250.0210.06725.50
5.6.240.0230.06225.51
5.6.230.0150.06625.55
5.6.220.0300.05625.45
5.6.210.0220.06425.52
5.6.200.0220.06425.79
5.6.190.0190.05625.68
5.6.180.0250.06225.76
5.6.170.0200.04425.80
5.6.160.0250.05825.69
5.6.150.0220.06225.62
5.6.140.0250.03925.71
5.6.130.0200.05225.79
5.6.120.0260.06425.79
5.6.110.0230.05725.68
5.6.100.0220.05425.72
5.6.90.0300.05925.60
5.6.80.0160.06825.49
5.6.70.0160.05125.41
5.6.60.0230.04225.40
5.6.50.0280.05325.49
5.6.40.0180.05925.41
5.6.30.0190.06425.44
5.6.20.0290.03425.40
5.6.10.0180.06125.39
5.6.00.0160.06825.37
5.5.380.0230.05225.31
5.5.370.0260.05625.33
5.5.360.0350.07225.44
5.5.350.0180.06825.34
5.5.340.0220.06325.68
5.5.330.0190.05625.67
5.5.320.0160.05125.56
5.5.310.0190.06425.46
5.5.300.0190.06625.61
5.5.290.0180.06625.62
5.5.280.0190.06325.48
5.5.270.0180.06125.59
5.5.260.0170.06525.48
5.5.250.0200.05425.45
5.5.240.0240.06225.22
5.5.230.0230.06325.27
5.5.220.0250.04225.27
5.5.210.0190.06225.30
5.5.200.0240.05025.37
5.5.190.0290.05925.22
5.5.180.0290.04125.27
5.5.170.0240.03423.23
5.5.160.0330.04925.31
5.5.150.0140.04625.30
5.5.140.0180.04925.20
5.5.130.0210.06925.28
5.5.120.0220.05625.25
5.5.110.0230.05725.30
5.5.100.0170.06425.17
5.5.90.0110.05225.12
5.5.80.0210.05825.21
5.5.70.0190.06725.11
5.5.60.0200.05325.19
5.5.50.0230.05926.89
5.5.40.0240.03627.08
5.5.30.0140.06227.05
5.5.20.0190.04627.24
5.5.10.0190.06827.15
5.5.00.0190.04827.10
5.4.450.0250.05725.05
5.4.440.0160.07125.04
5.4.430.0140.07225.03
5.4.420.0240.05725.11
5.4.410.0210.05524.97
5.4.400.0210.04124.70
5.4.390.0220.05924.92
5.4.380.0140.05024.82
5.4.370.0110.06825.01
5.4.360.0250.04024.79
5.4.350.0230.06224.83
5.4.340.0200.05925.00
5.4.330.0410.02421.74
5.4.320.0220.05424.85
5.4.310.0250.05325.01
5.4.300.0110.04924.96
5.4.290.0260.03624.78
5.4.280.0170.06224.89
5.4.270.0190.04824.88
5.4.260.0210.03924.87
5.4.250.0200.05324.78
5.4.240.0220.03524.87
5.4.230.0190.04624.68
5.4.220.0120.06824.77
5.4.210.0150.05524.93
5.4.200.0240.04924.64
5.4.190.0250.06024.88
5.4.180.0180.06224.81
5.4.170.0160.05924.89
5.4.160.0230.04724.68
5.4.150.0320.03624.95
5.4.140.0220.05623.65
5.4.130.0220.04823.50
5.4.120.0170.04823.45
5.4.110.0240.05123.51
5.4.100.0240.04323.59
5.4.90.0220.04723.51
5.4.80.0240.05423.73
5.4.70.0110.06623.50
5.4.60.0210.05823.44
5.4.50.0220.05823.59
5.4.40.0190.05723.58
5.4.30.0210.05923.48
5.4.20.0150.06023.56
5.4.10.0220.06423.53
5.4.00.0220.05323.21
5.3.290.0080.04822.58
5.3.280.0240.06222.63
5.3.270.0140.06422.53
5.3.260.0190.03722.74
5.3.250.0180.04722.58
5.3.240.0110.04522.58
5.3.230.0210.05722.62
5.3.220.0110.04722.54
5.3.210.0090.05522.56
5.3.200.0180.06122.53
5.3.190.0200.06422.61
5.3.180.0170.05422.65
5.3.170.0300.05322.64
5.3.160.0210.06022.63
5.3.150.0200.04522.54
5.3.140.0160.05922.55
5.3.130.0180.05122.54
5.3.120.0170.06622.50
5.3.110.0160.05122.54
5.3.100.0120.04622.32
5.3.90.0170.04822.31
5.3.80.0190.04022.10
5.3.70.0140.04122.12
5.3.60.0090.04622.14
5.3.50.0190.03422.10
5.3.40.0150.04322.14
5.3.30.0180.04322.18
5.3.20.0180.06221.95
5.3.10.0250.05021.89
5.3.00.0130.04120.03

preferences:
46.34 ms | 401 KiB | 5 Q