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.3.120.0130.12160.11
7.3.110.0230.10460.18
7.3.100.0240.11059.95
7.3.90.0200.10760.27
7.3.80.0260.10260.18
7.3.70.0390.10160.17
7.3.60.0430.09860.28
7.3.50.0300.10060.13
7.3.40.0260.10260.25
7.3.30.0230.10360.20
7.3.20.0390.09863.00
7.3.10.0200.11063.06
7.3.00.0340.09562.75
7.2.240.0300.09860.49
7.2.230.0100.12859.99
7.2.220.0170.11660.35
7.2.210.0270.10860.18
7.2.200.0300.10260.27
7.2.190.0390.09560.29
7.2.180.0300.11660.28
7.2.170.0030.12260.35
7.2.160.0170.11860.27
7.2.150.0240.10162.91
7.2.140.0200.10863.05
7.2.130.0200.10362.83
7.2.120.0170.10662.96
7.2.110.0460.08963.27
7.2.100.0410.09963.18
7.2.90.1240.09763.09
7.2.80.0070.10463.20
7.2.70.0360.10863.04
7.2.60.0200.12163.15
7.2.50.0640.14163.15
7.2.40.0640.09162.95
7.2.30.0260.12263.18
7.2.20.0470.10163.13
7.2.10.0420.11163.14
7.2.00.0490.10164.32
7.1.330.0400.13562.15
7.1.320.0300.12761.93
7.1.310.0200.14661.88
7.1.300.0230.15561.93
7.1.290.0230.13761.90
7.1.280.0170.14562.06
7.1.270.0230.13562.04
7.1.260.0160.14861.99
7.1.250.0330.14361.73
7.1.70.0100.08563.47
7.1.60.0100.14663.54
7.1.50.0130.13463.35
7.1.00.0130.17368.54
7.0.201.1470.09061.27
7.0.140.0000.18768.33
7.0.60.0300.12365.36
7.0.50.0230.17363.09
7.0.40.0200.17023.77
7.0.30.0270.11723.79
7.0.20.0630.16323.72
7.0.10.0270.17023.62
7.0.00.0200.17723.45
5.6.280.0100.26370.04
5.6.210.0230.25769.98
5.6.200.0230.25767.40
5.6.190.0330.24369.61
5.6.180.4000.19369.55
5.6.170.0330.22369.47
5.6.160.0330.24069.63
5.6.150.0230.23767.34
5.6.140.0130.20067.19
5.6.130.0230.19767.37
5.6.120.0230.17370.28
5.6.110.0170.22070.29
5.6.100.0370.22070.24
5.6.90.0270.23070.25
5.6.80.0230.24369.67
5.6.70.3470.19069.70
5.5.350.0470.21769.57
5.5.340.0230.21067.10
5.5.330.0130.21069.36
5.5.320.3500.19769.43
5.5.310.0430.23069.46
5.5.300.0300.18067.20
5.5.290.0200.24367.24
5.5.280.0170.19070.25
5.5.270.0270.24370.14
5.5.260.0230.24070.03
5.5.250.0230.21369.95
5.5.240.0370.21069.64
5.4.450.0470.31768.52
5.4.440.0430.35068.55
5.4.430.1230.34068.34
5.4.420.0430.34368.64
5.4.410.0430.34368.52
5.4.400.0630.28068.03
5.4.390.0330.33067.93
5.4.380.0870.30067.78
5.4.370.0470.34767.93
5.4.360.0470.32067.72
5.4.350.0830.29767.77
5.4.340.0730.29767.88
5.4.320.0360.20461.72
5.4.310.0370.20161.72
5.4.300.0340.21761.73
5.4.290.0430.20461.72
5.4.280.0390.21461.62
5.4.270.0530.29768.21
5.4.260.0300.35368.07
5.4.250.0700.36368.04
5.4.240.0670.34368.23
5.4.230.0470.31068.07
5.4.220.0630.33368.27
5.4.210.0330.34068.20
5.4.200.0300.34068.05
5.4.190.0500.36768.25
5.4.180.0370.32368.14
5.4.170.0370.31068.34
5.4.160.0330.30768.05
5.4.150.0370.35368.11
5.4.140.0370.38365.52
5.4.130.0270.32365.51
5.4.120.0470.30765.73
5.4.110.0370.34765.55
5.4.100.0300.32765.70
5.4.90.0430.39365.59
5.4.80.0500.45765.59
5.4.70.0530.31365.82
5.4.60.0330.35065.51
5.4.50.0630.31365.67
5.4.40.0370.34365.69
5.4.30.0500.43765.65
5.4.20.0230.40065.68
5.4.10.0500.34365.65
5.4.00.0800.39065.17
5.3.290.0300.24161.18
5.3.280.0500.32762.90
5.3.270.0330.38762.95
5.3.260.0100.41363.10
5.3.250.0530.41762.96
5.3.240.0600.41363.07
5.3.230.0370.41062.86
5.3.220.0400.38363.00
5.3.210.0230.39762.84
5.3.200.0300.32362.93
5.3.190.0530.30363.11
5.3.180.0470.38763.11
5.3.170.0430.40762.90
5.3.160.0570.34063.06
5.3.150.0430.37763.03
5.3.140.0730.48763.05
5.3.130.0470.38062.93
5.3.120.0470.35063.01
5.3.110.0700.38063.03
5.3.100.0500.36762.53
5.3.90.0370.32362.49
5.3.80.0330.37762.29
5.3.70.0400.36062.42
5.3.60.0470.39362.27
5.3.50.0270.43062.02
5.3.40.0330.39762.28
5.3.30.0230.32762.22
5.3.20.0570.42362.69
5.3.10.0400.59761.96
5.3.00.0600.48362.04
5.2.170.0770.45357.86
5.2.160.0430.31757.82
5.2.150.0500.39357.62
5.2.140.0430.28757.82
5.2.130.0270.34057.38
5.2.120.0170.33358.04
5.2.110.0500.30357.77
5.2.100.0500.37057.77
5.2.90.0300.34057.79
5.2.80.0230.38057.46
5.2.70.0430.39357.77
5.2.60.0430.30357.65
5.2.50.0530.32757.59
5.2.40.0330.33757.48
5.2.30.0300.34357.65
5.2.20.0670.65357.54
5.2.10.0430.58357.47
5.2.00.0830.64057.20
5.1.60.0530.74771.76
5.1.50.0570.70071.59
5.1.40.0470.76371.66
5.1.30.0370.63372.18
5.1.20.0700.88772.36
5.1.10.0470.84772.03
5.1.00.0430.71072.02
5.0.50.0630.74770.47
5.0.40.0530.96370.32
5.0.30.0730.96770.13
5.0.20.0530.79069.96
5.0.10.0670.91069.96
5.0.00.0501.03769.77
4.4.90.0600.67767.70
4.4.80.0400.59767.85
4.4.70.0730.56067.82
4.4.60.0470.59367.75
4.4.50.0370.59767.75
4.4.40.0500.90067.69
4.4.30.0370.63067.85
4.4.20.1070.82767.91
4.4.10.0270.62767.88
4.4.00.0570.78067.84
4.3.110.0730.71067.78
4.3.100.0670.63767.73
4.3.90.0600.67767.66
4.3.80.0400.61767.66
4.3.70.0500.60767.69
4.3.60.0470.67767.65
4.3.50.0470.63067.93
4.3.40.0730.81767.89
4.3.30.0700.75766.61
4.3.20.0400.67366.60
4.3.10.0600.93766.64
4.3.00.0600.66066.57

preferences:
34.78 ms | 401 KiB | 5 Q