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

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.0260.15259.98
7.3.120.0230.16260.26
7.3.110.0270.11560.21
7.3.100.0370.12060.12
7.3.90.0130.14860.24
7.3.80.0400.11760.02
7.3.70.0360.10559.93
7.3.60.0100.11160.10
7.3.50.0300.09360.20
7.3.40.0140.10860.00
7.3.30.0330.09560.05
7.3.20.0100.10462.79
7.3.10.0230.09062.67
7.3.00.0400.10262.69
7.2.250.0170.13460.07
7.2.240.0370.15360.07
7.2.230.0200.11159.87
7.2.220.0370.10059.82
7.2.210.0330.12360.38
7.2.200.0230.10060.15
7.2.190.0130.15860.17
7.2.180.0160.13560.10
7.2.170.0100.11960.00
7.2.130.0400.10963.11
7.2.120.0330.12962.98
7.2.110.0540.10863.02
7.2.100.0650.10962.97
7.2.90.0810.09862.75
7.2.80.0590.10262.77
7.2.70.0510.09662.79
7.2.60.1010.09562.62
7.2.50.0510.13462.96
7.2.40.0630.10462.77
7.2.30.0510.12862.94
7.2.20.0540.10962.75
7.2.10.0730.10962.64
7.2.00.0700.09964.20
7.1.330.0030.15562.13
7.1.320.0100.13961.92
7.1.310.0100.14962.11
7.1.300.0070.14561.91
7.1.290.0030.13761.73
7.1.280.0100.13161.79
7.1.270.0100.15261.80
7.1.260.0160.13161.82
7.1.250.0490.15061.97
7.1.240.0470.15661.70
7.1.230.0490.16561.70
7.1.220.0580.14661.71
7.1.210.0790.15161.74
7.1.200.0620.14561.73
7.1.190.0640.14261.96
7.1.180.0340.15961.86
7.1.170.0830.13961.83
7.1.160.0470.15161.68
7.1.150.0440.15561.61
7.1.140.0750.14761.73
7.1.130.0640.14561.59
7.1.120.0430.15861.35
7.1.110.0570.16361.67
7.1.100.0480.16661.68
7.1.90.0710.14361.59
7.1.80.0630.16961.74
7.1.70.0640.11862.47
7.1.60.0310.15462.68
7.1.50.0570.11362.52
7.1.40.0560.15861.81
7.1.30.0560.14261.51
7.1.20.0750.13661.57
7.1.10.0660.15961.65
7.1.00.0430.16265.03
7.0.330.0460.15561.29
7.0.320.0680.14061.60
7.0.310.0600.15061.68
7.0.300.0530.14461.09
7.0.290.0560.14561.59
7.0.280.0330.16161.43
7.0.270.0500.16661.52
7.0.260.0630.14261.55
7.0.250.0620.14061.13
7.0.240.0950.15761.25
7.0.230.0440.17461.22
7.0.220.0330.17761.35
7.0.210.0500.15861.13
7.0.200.5050.12660.90
7.0.190.0640.13961.27
7.0.180.0900.14661.20
7.0.170.0540.17361.46
7.0.160.0720.13761.45
7.0.150.0530.15261.15
7.0.140.0530.16564.78
7.0.130.0530.14861.08
7.0.120.0330.16464.75
7.0.110.0880.15661.23
7.0.100.0860.13161.54
7.0.90.0690.13561.52
7.0.80.0760.16261.71
7.0.70.0770.14161.50
7.0.60.0360.15263.46
7.0.50.0420.17062.50
7.0.40.0130.17321.40
7.0.30.0310.14621.41
7.0.20.0250.14421.45
7.0.10.0190.16721.39
7.0.00.0100.14521.28
5.6.380.0450.21463.55
5.6.370.0270.23663.48
5.6.360.0300.23363.63
5.6.350.0350.22363.77
5.6.340.0430.22163.41
5.6.330.0400.20463.54
5.6.320.0360.22863.53
5.6.310.0170.25863.68
5.6.300.0470.21863.73
5.6.290.0430.23363.37
5.6.280.0330.24967.05
5.6.270.0330.22763.41
5.6.260.0400.22963.02
5.6.250.0360.22463.14
5.6.240.0500.22364.00
5.6.230.0520.22663.79
5.6.220.0410.23063.59
5.6.210.0290.23366.81
5.6.200.0300.22565.47
5.6.190.0250.24566.60
5.6.180.0480.23066.68
5.6.170.0330.23066.43
5.6.160.0370.20866.54
5.6.150.0290.19765.42
5.6.140.0380.22265.62
5.6.130.0330.23165.56
5.6.120.0350.22067.13
5.6.110.0340.22466.92
5.6.100.0300.21767.02
5.6.90.0250.20567.02
5.6.80.0320.24366.67
5.6.70.0360.22863.75
5.6.60.0370.23363.33
5.6.50.0330.22763.58
5.6.40.0340.22863.55
5.6.30.0200.24763.41
5.6.20.0340.22763.80
5.6.10.0340.21763.61
5.6.00.0230.23063.61
5.5.380.0270.25260.52
5.5.370.0260.25260.45
5.5.360.0230.22760.58
5.5.350.0420.22664.98
5.5.340.0260.23563.73
5.5.330.0300.24365.03
5.5.320.1620.21264.85
5.5.310.0420.24164.84
5.5.300.0320.23663.75
5.5.290.0300.25563.88
5.5.280.0270.21165.36
5.5.270.0340.22065.14
5.5.260.0320.22865.34
5.5.250.0300.25065.12
5.5.240.0230.20165.00
5.5.230.0260.22460.24
5.5.220.0360.21960.35
5.5.210.0270.23160.31
5.5.200.0230.23260.28
5.5.190.0260.22360.31
5.5.180.0260.24960.66
5.5.170.0390.21160.27
5.5.160.0330.22160.36
5.5.150.0270.22660.52
5.5.140.0390.24360.43
5.5.130.0430.21160.50
5.5.120.0270.23160.50
5.5.110.0400.22960.41
5.5.100.0330.22860.38
5.5.90.0440.22160.43
5.5.80.0270.22760.27
5.5.70.0300.22360.20
5.5.60.0240.23160.34
5.5.50.0270.24859.96
5.5.40.0230.26860.35
5.5.30.0360.22960.43
5.5.20.0460.23460.48
5.5.10.0500.20660.27
5.5.00.0370.21660.17
5.4.450.0380.20764.34
5.4.440.0350.23564.47
5.4.430.0330.23764.32
5.4.420.0280.24964.46
5.4.410.0370.21264.50
5.4.400.0300.21464.36
5.4.390.0420.24764.21
5.4.380.0300.23664.30
5.4.370.0400.20964.17
5.4.360.0380.23164.35
5.4.350.0340.21064.37
5.4.340.0300.23664.34
5.4.330.0300.23660.43
5.4.320.0310.23264.30
5.4.310.0300.23664.20
5.4.300.0230.22564.32
5.4.290.0190.22964.37
5.4.280.0230.20464.31
5.4.270.0210.25564.39
5.4.260.0170.22564.36
5.4.250.0200.23964.07
5.4.240.0310.23064.23
5.4.230.0430.19864.32
5.4.220.0260.19664.02
5.4.210.0190.21564.29
5.4.200.0250.22264.33
5.4.190.0200.24264.29
5.4.180.0300.19564.25
5.4.170.0250.21664.29
5.4.160.0280.21064.24
5.4.150.0290.21564.06
5.4.140.0520.19462.95
5.4.130.0240.21363.00
5.4.120.0120.21462.95
5.4.110.0250.21362.88
5.4.100.0280.22262.84
5.4.90.0430.19862.91
5.4.80.0310.22662.90
5.4.70.0170.24462.93
5.4.60.0490.21462.80
5.4.50.0240.23062.93
5.4.40.0230.24462.79
5.4.30.0240.21662.89
5.4.20.0260.21862.88
5.4.10.0250.24362.89
5.4.00.0180.24062.74
5.3.290.0250.22860.91
5.3.280.0170.23060.83
5.3.270.0300.23360.78
5.3.260.0230.26860.88
5.3.250.0270.23560.83
5.3.240.0220.22860.79
5.3.230.0260.24460.80
5.3.220.0180.24160.88
5.3.210.0160.23660.76
5.3.200.0280.24860.82
5.3.190.0230.25060.91
5.3.180.0290.21660.89
5.3.170.0150.26360.73
5.3.160.0420.23160.85
5.3.150.0300.25560.72
5.3.140.0240.25560.93
5.3.130.0200.25960.78
5.3.120.0250.25260.89
5.3.110.0200.24460.77
5.3.100.0230.26160.54
5.3.90.0390.23160.64
5.3.80.0210.22960.33
5.3.70.0280.23960.39
5.3.60.0250.25860.46
5.3.50.0170.25760.42
5.3.40.0250.22560.34
5.3.30.0300.24660.40
5.3.20.0230.26460.29
5.3.10.0180.37260.18
5.3.00.0200.37860.23
5.2.170.0270.24956.74
5.2.160.0180.23856.77
5.2.150.0220.23856.72
5.2.140.0250.23856.61
5.2.130.0230.24156.72
5.2.120.0200.24556.58
5.2.110.0260.23356.71
5.2.100.0250.23156.54
5.2.90.0260.22956.63
5.2.80.0150.25856.49
5.2.70.0200.26056.63
5.2.60.0200.22556.65
5.2.50.0250.23856.54
5.2.40.0310.24356.53
5.2.30.0250.23656.41
5.2.20.0230.43056.54
5.2.10.0230.46756.51
5.2.00.0200.41956.40
5.1.60.0350.38170.78
5.1.50.0300.42270.87
5.1.40.0300.41371.04
5.1.30.0200.39371.05
5.1.20.0310.41471.08
5.1.10.0320.54471.08
5.1.00.0250.41571.09
5.0.50.0150.47069.74
5.0.40.0200.49269.58
5.0.30.0220.53569.46
5.0.20.0220.50369.37
5.0.10.0220.51669.40
5.0.00.0370.48569.43
4.4.90.0200.42467.32
4.4.80.0230.41767.38
4.4.70.0150.44467.44
4.4.60.0280.41567.31
4.4.50.0270.45067.37
4.4.40.0850.39167.40
4.4.30.0230.41367.38
4.4.20.0230.41467.48
4.4.10.0270.42567.33
4.4.00.0220.38567.33
4.3.110.0220.39667.29
4.3.100.0380.42867.22
4.3.90.0230.40867.22
4.3.80.0270.43167.23
4.3.70.0250.40467.17
4.3.60.0300.41367.15
4.3.50.0280.41667.45
4.3.40.0250.44367.51
4.3.30.0230.43166.48
4.3.20.0130.47066.48
4.3.10.0200.47166.59
4.3.00.0300.44166.52

preferences:
30.51 ms | 401 KiB | 5 Q