3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array(); for($i = 0; $i < pow(10, 5); $i++) { $a[$i] = array( md5($i.microtime(true)) ); } $sum = 0; $times['for']['before'] = microtime(true); for($j = 0; $i < count($a); $i++) { $sum += 1000; } $times['for']['after'] = microtime(true); unset($sum); $sum = 0; $times['foreach']['before'] = microtime(true); foreach($a as $k) { $sum += 1000; } $times['foreach']['after'] = microtime(true); unset($sum); $t_for = $times['for']['after'] - $times['for']['before']; $t_foreach = $times['foreach']['after'] - $times['foreach']['before']; var_dump(array( 'for' => sprintf('%f', $t_for), 'foreach' => sprintf('%f', $t_foreach), 'is "for" faster than "foreach"?' => $t_for < $t_foreach, 'how much faster?' => (1 - ($t_for / $t_foreach))) );

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.00.0530.13660.04
7.3.120.0300.15760.47
7.3.110.0400.11960.40
7.3.100.0200.11460.07
7.3.90.0310.10559.87
7.3.80.0260.12160.28
7.3.70.0270.09860.20
7.3.60.0100.11760.09
7.3.50.0260.10560.25
7.3.40.0230.11959.92
7.3.30.0300.09660.16
7.3.20.0240.11262.80
7.3.10.0100.10762.79
7.3.00.0230.09162.83
7.2.250.0330.15660.54
7.2.240.0300.11360.36
7.2.230.0200.13360.49
7.2.220.0230.11060.31
7.2.210.0200.11760.54
7.2.200.0300.09960.43
7.2.190.0230.10460.42
7.2.180.0200.10960.03
7.2.170.0230.10260.39
7.2.00.0370.08165.47
7.1.330.0330.15662.14
7.1.320.0130.14361.73
7.1.310.0260.15261.75
7.1.300.0130.14862.10
7.1.290.0200.13261.98
7.1.280.0200.13362.03
7.1.270.0070.14361.96
7.1.260.0300.15062.22
7.1.70.0000.12263.15
7.1.60.0070.10663.60
7.1.50.0410.13463.40
7.1.00.0070.19068.44
7.0.200.6340.14561.72
7.0.140.0130.17768.23
7.0.60.0170.17365.23
7.0.50.0070.19063.09
7.0.40.0030.13323.64
7.0.30.0570.12323.46
7.0.20.0500.16323.79
7.0.10.0170.19023.71
7.0.00.0100.16023.78
5.6.280.0230.26770.17
5.6.210.0200.24369.99
5.6.200.0170.17767.33
5.6.190.0270.22369.56
5.6.180.0400.22369.41
5.6.170.0330.21069.64
5.6.160.0170.18769.64
5.6.150.0270.24367.35
5.6.140.0230.25767.34
5.6.130.0270.22367.29
5.6.120.0200.24770.29
5.6.110.0230.25770.15
5.6.100.0270.23770.29
5.6.90.0130.27770.38
5.6.80.0470.19769.68
5.5.350.0130.18069.64
5.5.340.0170.19367.20
5.5.330.0330.24069.28
5.5.320.0100.26369.42
5.5.310.0470.23369.36
5.5.300.0300.25367.20
5.5.290.0170.25767.19
5.5.280.0230.25370.04
5.5.270.0100.25770.10
5.5.260.0230.24070.13
5.5.250.0370.23069.93
5.5.240.0300.26069.55
5.4.450.1030.29068.35
5.4.440.1200.32768.51
5.4.430.1070.30368.39
5.4.420.0970.34768.50
5.4.410.1400.34768.49
5.4.400.1630.37768.50
5.4.390.1170.30368.29
5.4.380.0770.30367.94
5.4.370.0630.31067.96
5.4.360.0600.31067.96
5.4.350.0630.28367.75
5.4.340.0730.28767.91
5.4.320.0410.20861.73
5.4.310.0390.20661.72
5.4.300.0400.21861.73
5.4.290.0420.20161.72
5.4.280.0490.20661.62
5.4.270.0270.32068.06
5.4.260.0330.34067.94
5.4.250.0370.31768.19
5.4.240.0500.31768.03
5.4.230.0530.31368.12
5.4.220.0470.37067.90
5.4.210.0430.36368.03
5.4.200.0630.35068.18
5.4.190.0670.29768.13
5.4.180.0330.34768.18
5.4.170.0770.29068.15
5.4.160.0700.32767.93
5.4.150.0630.42768.13
5.4.140.0300.35365.56
5.4.130.0430.31365.73
5.4.120.0470.27765.81
5.4.110.0470.30365.68
5.4.100.0330.30765.72
5.4.90.0500.29365.52
5.4.80.0570.41765.50
5.4.70.0570.39065.65
5.4.60.0430.35065.42
5.4.50.0430.29765.46
5.4.40.0630.30765.59
5.4.30.0600.31365.36
5.4.20.0370.29765.57
5.4.10.0570.32365.57
5.4.00.0500.31765.26
5.3.290.0360.23561.18
5.3.280.0430.34762.96
5.3.270.0430.45063.11
5.3.260.0600.50063.07
5.3.250.0470.46363.07
5.3.240.0270.40762.94
5.3.230.0500.35762.92
5.3.220.0600.33762.95
5.3.210.0430.37362.90
5.3.200.0330.35062.83
5.3.190.0400.32362.97
5.3.180.0470.37763.11
5.3.170.0500.48062.69
5.3.160.0630.41763.04
5.3.150.0630.33062.88
5.3.140.0430.38063.09
5.3.130.0430.36062.95
5.3.120.0530.47762.98
5.3.110.0370.36062.99
5.3.100.0600.40062.40
5.3.90.0430.39362.48
5.3.80.0330.38762.30
5.3.70.0370.41762.29
5.3.60.0630.41062.36
5.3.50.0430.35062.43
5.3.40.0730.49062.20
5.3.30.0330.31362.32
5.3.20.0300.36761.86
5.3.10.0270.53762.02
5.3.00.0230.49062.11
5.2.170.0700.32757.77
5.2.160.0370.35358.17
5.2.150.0370.35057.84
5.2.140.0300.32357.54
5.2.130.0300.31357.70
5.2.120.0300.32057.78
5.2.110.0400.33057.80
5.2.100.0230.34357.50
5.2.90.0300.32757.69
5.2.80.0330.32357.61
5.2.70.0300.33357.78
5.2.60.0430.31757.52
5.2.50.0430.36757.51
5.2.40.0230.49057.51
5.2.30.0370.42057.27
5.2.20.0370.54357.47
5.2.10.0170.62057.34
5.2.00.0270.58757.33
5.1.60.0570.66771.71
5.1.50.0670.66371.88
5.1.40.0330.80071.77
5.1.30.0700.64072.34
5.1.20.0570.68072.03
5.1.10.0500.69771.66
5.1.00.0470.76771.83
5.0.50.0570.79770.46
5.0.40.0600.80070.27
5.0.30.0570.83070.08
5.0.20.0330.72070.00
5.0.10.0400.77070.18
5.0.00.0831.11770.07
4.4.90.0370.57067.82
4.4.80.0500.67367.82
4.4.70.0500.67367.68
4.4.60.0370.73067.85
4.4.50.0530.64367.70
4.4.40.0330.71367.86
4.4.30.0330.61367.76
4.4.20.0400.61767.86
4.4.10.0630.75367.92
4.4.00.0400.67767.71
4.3.110.0470.69367.62
4.3.100.0470.65767.62
4.3.90.0430.63367.70
4.3.80.0530.73067.68
4.3.70.0570.66067.67
4.3.60.0630.74067.83
4.3.50.0530.73367.91
4.3.40.0530.70367.88
4.3.30.0230.61766.61
4.3.20.0500.63366.77
4.3.10.0430.68366.63
4.3.00.0600.70366.52

preferences:
32.24 ms | 401 KiB | 5 Q