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)) * 100).'%' ));

Abusive script

This script was stopped while abusing our resources

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.10.0300.12160.09
7.4.00.0270.16060.49
7.3.130.0570.13060.39
7.3.120.0490.13660.11
7.3.110.0330.13260.27
7.3.100.0260.10859.89
7.3.90.0300.10360.09
7.3.80.0340.13260.05
7.3.70.0240.10559.98
7.3.60.0260.11060.09
7.3.50.0100.11859.98
7.3.40.0430.08759.95
7.3.30.0300.10360.07
7.3.20.0230.09863.03
7.3.10.0140.10162.79
7.3.00.0270.11062.94
7.2.260.0360.15260.33
7.2.250.0240.12160.45
7.2.240.0130.14260.53
7.2.230.0460.10560.59
7.2.220.0400.09260.49
7.2.210.0200.11560.38
7.2.200.0270.10060.29
7.2.190.0330.11760.45
7.2.180.0230.14060.32
7.2.170.0330.11560.34
7.2.160.0200.11060.13
7.2.150.0200.09363.29
7.2.140.0270.09163.28
7.2.130.0600.11163.15
7.2.120.0100.11063.28
7.2.110.0200.10063.14
7.2.100.2510.10963.14
7.2.90.0130.11563.10
7.2.80.0130.12763.09
7.2.70.0640.11263.06
7.2.60.0340.11562.95
7.2.50.0230.00011.82
7.2.40.0200.13262.84
7.2.30.0270.10963.30
7.2.20.0200.10963.12
7.2.10.0400.11363.16
7.2.00.2460.10563.79
7.1.330.0160.13562.17
7.1.320.0200.17761.99
7.1.310.0190.15362.18
7.1.300.0130.13361.78
7.1.290.0130.14662.03
7.1.280.0130.13561.96
7.1.270.0230.14361.98
7.1.260.0200.14362.03
7.1.250.0100.15361.95
7.1.240.0170.16162.15
7.1.230.0070.16061.77
7.1.220.0140.14961.70
7.1.210.0270.14961.90
7.1.200.1160.14261.91
7.1.190.0230.13962.08
7.1.180.0230.14161.77
7.1.170.0250.14062.11
7.1.160.0260.13662.17
7.1.150.0200.13562.16
7.1.140.0660.15662.05
7.1.130.0100.15362.12
7.1.120.0240.13962.00
7.1.110.0180.14161.98
7.1.100.0270.13361.96
7.1.90.0260.14562.14
7.1.80.0370.12462.21
7.1.70.0400.13662.74
7.1.60.0180.14962.59
7.1.50.0180.11971.47
7.1.40.0400.15462.01
7.1.30.0270.16161.75
7.1.20.0210.0009.55
7.1.10.0250.13962.16
7.1.00.0160.08238.99
7.0.330.0230.15161.63
7.0.320.0070.14061.56
7.0.310.0290.13761.66
7.0.300.0340.14261.75
7.0.290.0200.14461.73
7.0.280.0270.14461.39
7.0.270.0360.16261.75
7.0.260.0270.15961.90
7.0.250.0380.14261.76
7.0.240.0270.14061.89
7.0.230.0210.14761.72
7.0.220.0300.13361.47
7.0.210.0220.14361.74
7.0.200.3370.13061.12
7.0.190.0300.14061.86
7.0.180.0200.16261.79
7.0.170.0310.14861.47
7.0.160.0230.14561.79
7.0.150.0110.00911.16
7.0.140.0120.09239.69
7.0.130.0210.13761.77
7.0.120.0090.10038.74
7.0.110.0310.15061.84
7.0.100.0080.01310.97
7.0.90.0290.16261.52
7.0.80.0170.16161.84
7.0.70.0330.14361.80
7.0.60.0750.16663.51
7.0.50.0240.16162.24
7.0.40.0170.16120.31
7.0.30.0210.15620.38
7.0.20.0180.16320.25
7.0.10.0120.13920.24
7.0.00.0170.15320.35
5.6.400.0200.22363.23
5.6.390.0170.24163.93
5.6.380.0130.22763.56
5.6.370.0200.23663.84
5.6.360.0160.24663.93
5.6.350.0490.21463.73
5.6.340.0400.23663.50
5.6.330.0210.0039.21
5.6.320.0160.0048.09
5.6.310.0190.0008.09
5.6.300.0520.23563.95
5.6.290.0240.25363.38
5.6.280.0340.23867.17
5.6.270.0300.25863.49
5.6.260.0370.25863.85
5.6.250.0500.20963.70
5.6.240.0390.21763.75
5.6.230.0270.23363.86
5.6.220.0190.24163.71
5.6.210.0550.22766.63
5.6.200.0250.16650.48
5.6.190.0300.21065.61
5.6.180.0350.24865.53
5.6.170.0280.24665.48
5.6.160.0250.24065.47
5.6.150.0300.23265.65
5.6.140.0360.22165.62
5.6.130.0350.23665.69
5.6.120.0310.19165.45
5.6.110.0220.23065.40
5.6.100.0220.25165.47
5.6.90.0240.22165.49
5.6.80.0270.22865.21
5.6.70.0260.24065.14
5.6.60.0220.25565.35
5.6.50.0290.23965.27
5.6.40.0330.22465.09
5.6.30.0230.23365.15
5.6.20.0170.23765.24
5.6.10.0350.24565.18
5.6.00.0330.24065.18
5.5.380.0170.24663.89
5.5.370.0390.24263.96
5.5.360.0270.26563.67
5.5.350.0380.22966.68
5.5.340.0350.23865.48
5.5.330.0400.23265.47
5.5.320.0390.23765.64
5.5.310.0320.23065.33
5.5.300.0200.24165.42
5.5.290.0320.20265.33
5.5.280.0280.23165.37
5.5.270.0230.23865.37
5.5.260.0320.22565.35
5.5.250.0310.24865.29
5.5.240.0250.25565.05
5.5.230.0320.24265.06
5.5.220.0290.24964.95
5.5.210.0420.23065.13
5.5.200.0250.22265.19
5.5.190.0200.24164.94
5.5.180.0230.21065.02
5.5.170.0460.27163.86
5.5.160.0300.23865.18
5.5.150.0290.25665.00
5.5.140.0200.24765.20
5.5.130.0350.22865.01
5.5.120.0260.24665.08
5.5.110.0230.24965.11
5.5.100.0250.20965.05
5.5.90.0240.23765.02
5.5.80.0380.23364.96
5.5.70.0270.22664.86
5.5.60.0320.23564.99
5.5.50.0290.22065.05
5.5.40.0190.23865.14
5.5.30.0290.23264.96
5.5.20.0300.22865.15
5.5.10.0260.21565.01
5.5.00.0270.25764.96
5.4.450.0230.24464.38
5.4.440.0230.25664.47
5.4.430.0290.22564.36
5.4.420.0300.23864.32
5.4.410.0320.23364.42
5.4.400.0250.23764.18
5.4.390.0170.24764.22
5.4.380.0350.22664.22
5.4.370.0270.24464.23
5.4.360.0380.21864.36
5.4.350.0170.23764.16
5.4.340.0170.21164.21
5.4.330.0450.23760.20
5.4.320.0320.22364.21
5.4.310.0270.23264.22
5.4.300.0300.19964.30
5.4.290.0280.21764.41
5.4.280.0210.24564.28
5.4.270.0220.24664.18
5.4.260.0280.24064.17
5.4.250.0280.21564.33
5.4.240.0380.24364.14
5.4.230.0230.20264.19
5.4.220.0170.21764.19
5.4.210.0200.21864.11
5.4.200.0310.21664.34
5.4.190.0220.21264.08
5.4.180.0250.21564.30
5.4.170.0250.23564.25
5.4.160.0220.24864.20
5.4.150.0230.22964.25
5.4.140.0200.21162.83
5.4.130.0200.22862.96
5.4.120.0250.23862.93
5.4.110.0300.21362.95
5.4.100.0170.22562.98
5.4.90.0250.24462.92
5.4.80.0130.24063.00
5.4.70.0270.22962.80
5.4.60.0300.21563.00
5.4.50.0250.24962.93
5.4.40.0200.23762.96
5.4.30.0220.27663.00
5.4.20.0250.23162.91
5.4.10.0220.24162.95
5.4.00.0330.23362.55
5.3.290.0230.25561.02
5.3.280.0180.23960.78
5.3.270.0220.27160.82
5.3.260.0350.25560.79
5.3.250.0300.27560.95
5.3.240.0280.27460.80
5.3.230.0250.26660.84
5.3.220.0190.24960.74
5.3.210.0180.24160.83
5.3.200.0190.26060.74
5.3.190.0230.26960.69
5.3.180.0180.26160.88
5.3.170.0200.23960.81
5.3.160.0440.24560.74
5.3.150.0230.25460.77
5.3.140.0300.27960.88
5.3.130.0230.27960.85
5.3.120.0240.22460.82
5.3.110.0240.26960.85
5.3.100.0180.23860.49
5.3.90.0200.23260.54
5.3.80.0270.22260.40
5.3.70.0160.23560.44
5.3.60.0290.24160.56
5.3.50.0230.22660.35
5.3.40.0130.22660.46
5.3.30.0250.20360.50
5.3.20.0240.20860.34
5.3.10.0270.33560.13
5.3.00.0170.33660.17
5.2.170.0130.18357.60
5.2.160.0030.17057.59
5.2.150.0070.17057.57
5.2.140.0030.17757.58
5.2.130.0130.16357.57
5.2.120.0030.17057.35
5.2.110.0070.20057.65
5.2.100.0130.17057.55
5.2.90.0100.17357.57
5.2.80.0100.16757.35
5.2.70.0170.16057.57
5.2.60.0200.17757.47
5.2.50.0370.22057.25
5.2.40.0270.23357.34
5.2.30.0200.24757.22
5.2.20.0170.35057.86
5.2.10.0230.36757.32
5.2.00.0230.35757.18
5.1.60.0300.36371.54
5.1.50.0100.38771.66
5.1.40.0230.35371.59
5.1.30.1000.37372.04
5.1.20.0270.42072.07
5.1.10.0230.39771.80
5.1.00.0100.42371.68
5.0.50.0170.47070.22
5.0.40.0170.50370.03
5.0.30.0300.45069.92
5.0.20.0230.52370.04
5.0.10.0300.40769.95
5.0.00.0130.46069.92
4.4.90.0070.31367.69
4.4.80.0130.37067.66
4.4.70.0270.36367.72
4.4.60.0170.32067.69
4.4.50.0200.33367.71
4.4.40.0230.32067.73
4.4.30.0130.31067.67
4.4.20.0070.39367.70
4.4.10.0330.36367.70
4.4.00.0170.36767.76
4.3.110.0130.42067.62
4.3.100.0130.37067.64
4.3.90.0400.37067.53
4.3.80.0230.39767.53
4.3.70.0170.38367.61
4.3.60.0100.35367.61
4.3.50.0130.40767.84
4.3.40.0200.40067.77
4.3.30.0170.39766.51
4.3.20.0100.40766.45
4.3.10.0370.38766.47
4.3.00.0230.39066.52

preferences:
37.26 ms | 401 KiB | 5 Q