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' => (float) $t_for, 'foreach' => (float) $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.2.00.0230.07465.73
7.1.70.0030.11663.52
7.1.60.0390.08263.35
7.1.50.0230.14463.42
7.1.00.0100.18068.59
7.0.200.1190.08663.08
7.0.140.0100.18368.39
7.0.100.0530.15065.20
7.0.90.0170.18065.44
7.0.80.0370.17065.20
7.0.70.0330.20065.21
7.0.60.0330.18065.16
7.0.50.0530.17765.60
7.0.40.0230.17723.84
7.0.30.0100.21723.96
7.0.20.0170.18723.98
7.0.10.0170.20323.88
7.0.00.0100.18723.88
5.6.280.0230.25770.29
5.6.250.0300.25069.93
5.6.240.0400.23769.91
5.6.230.0270.23369.83
5.6.220.0200.22769.88
5.6.210.0170.24769.81
5.6.200.0330.26770.38
5.6.190.0200.25070.20
5.6.180.0200.25370.26
5.6.170.0300.22070.29
5.6.160.0470.25370.27
5.6.150.0270.25370.43
5.6.140.0200.25370.20
5.6.130.0370.22770.28
5.6.120.0400.22770.21
5.6.110.0330.24370.32
5.6.100.0270.23770.37
5.6.90.0200.26370.13
5.6.80.0270.22069.59
5.6.70.0100.22369.59
5.6.60.0330.24369.67
5.6.50.0230.22769.79
5.6.40.0300.22069.64
5.6.30.0200.19069.63
5.6.20.0200.20769.57
5.6.10.0170.19069.79
5.6.00.0130.18769.55
5.5.380.0200.24369.76
5.5.370.0170.25369.62
5.5.360.0300.23069.67
5.5.350.0330.23069.68
5.5.340.0130.26070.07
5.5.330.0370.23770.17
5.5.320.0170.25370.07
5.5.310.0430.24370.15
5.5.300.0300.22370.14
5.5.290.0270.25770.02
5.5.280.0370.22369.99
5.5.270.0170.24770.08
5.5.260.0400.23070.09
5.5.250.0200.25069.69
5.5.240.0130.26069.54
5.5.230.0300.28069.44
5.5.220.0330.22769.54
5.5.210.0170.25069.56
5.5.200.0130.24769.39
5.5.190.0430.23069.41
5.5.180.0170.26369.34
5.5.160.0200.18069.26
5.5.150.0100.23369.41
5.5.140.0130.22369.53
5.5.130.0170.18769.41
5.5.120.0330.20369.25
5.5.110.0200.19769.52
5.5.100.0270.19069.38
5.5.90.0200.17769.37
5.5.80.0200.18069.43
5.5.70.0270.17369.41
5.5.60.0100.18769.37
5.5.50.0070.19069.32
5.5.40.0200.18369.19
5.5.30.0300.24769.31
5.5.20.0100.23769.31
5.5.10.0170.23369.21
5.5.00.0400.25369.30
5.4.450.0200.24068.48
5.4.440.0200.26068.58
5.4.430.0230.23768.55
5.4.420.0330.25068.47
5.4.410.0430.23768.49
5.4.400.0400.21068.19
5.4.390.0270.25768.25
5.4.380.0200.24068.02
5.4.370.0270.23068.25
5.4.360.0300.25768.23
5.4.350.0170.23768.17
5.4.340.0300.21368.18
5.4.320.0300.17368.35
5.4.310.0370.23368.15
5.4.300.0130.21068.16
5.4.290.0130.25068.24
5.4.280.0170.21068.24
5.4.270.0070.19068.29
5.4.260.0230.17768.25
5.4.250.0230.17368.18
5.4.240.0170.18368.23
5.4.230.0100.18768.34
5.4.220.0230.24768.15
5.4.210.0300.23768.16
5.4.200.0400.22768.16
5.4.190.0230.22768.15
5.4.180.0230.24768.14
5.4.170.0330.25368.15
5.4.160.0100.22068.18
5.4.150.0130.24368.22
5.4.140.0230.25365.56
5.4.130.0270.23065.55
5.4.120.0270.22765.56
5.4.110.0100.25065.44
5.4.100.0230.23065.68
5.4.90.0300.25065.65
5.4.80.0230.23065.53
5.4.70.0200.24765.51
5.4.60.0170.24365.58
5.4.50.0170.25365.48
5.4.40.0230.24065.65
5.4.30.0370.24065.52
5.4.20.0370.22065.46
5.4.10.0230.24065.42
5.4.00.0270.24064.92
5.3.290.0300.18362.96
5.3.280.0300.17062.94
5.3.270.0170.24362.90
5.3.260.0170.28062.77
5.3.250.0200.26762.94
5.3.240.0230.25062.79
5.3.230.0330.26362.89
5.3.220.0200.24062.84
5.3.210.0370.25062.84
5.3.200.0130.26362.74
5.3.190.0070.25362.76
5.3.180.0330.25362.70
5.3.170.0270.23362.91
5.3.160.0300.24762.74
5.3.150.0200.26762.79
5.3.140.0270.24062.89
5.3.130.0200.27062.79
5.3.120.0230.22362.75
5.3.110.0230.25062.74
5.3.100.0300.25062.28
5.3.90.0300.26362.28
5.3.80.0130.21762.29
5.3.70.0300.24762.28
5.3.60.0130.24362.22
5.3.50.0270.19062.13
5.3.40.0400.25062.21
5.3.30.0270.22762.03
5.3.20.0130.26061.92
5.3.10.0330.35361.90
5.3.00.0330.37061.76
5.2.170.0300.23057.55
5.2.160.0200.23057.58
5.2.150.0100.20757.63
5.2.140.0170.24357.40
5.2.130.0200.21057.53
5.2.120.0130.23757.53
5.2.110.0170.22357.57
5.2.100.0430.22757.52
5.2.90.0200.21057.57
5.2.80.0330.23757.54
5.2.70.0130.23757.61
5.2.60.0100.23057.45
5.2.50.0300.24057.46
5.2.40.0200.22357.40
5.2.30.0300.20757.29
5.2.20.0170.35057.36
5.2.10.0130.42757.25
5.2.00.0230.40057.05
5.1.60.0230.38771.54
5.1.50.0230.38071.81
5.1.40.0200.37071.66
5.1.30.0330.39072.07
5.1.20.0200.42072.20
5.1.10.0130.41371.76
5.1.00.0330.39771.86
5.0.50.0130.45370.27
5.0.40.0370.42770.11
5.0.30.0130.49069.97
5.0.20.0270.44369.93
5.0.10.0400.42769.98
5.0.00.0170.50069.87
4.4.90.0230.40367.76
4.4.80.0230.40067.67
4.4.70.0130.37367.71
4.4.60.0270.44067.75
4.4.50.0170.39067.73
4.4.40.0230.37067.69
4.4.30.0270.35767.69
4.4.20.0130.37067.76
4.4.10.0230.34067.72
4.4.00.0300.39367.75
4.3.110.0200.37067.61
4.3.100.0370.30067.63
4.3.90.0330.46767.61
4.3.80.0230.42067.64
4.3.70.0300.42767.61
4.3.60.0200.37367.65
4.3.50.0200.38767.88
4.3.40.0230.39367.80
4.3.30.0130.40366.49
4.3.20.0270.36766.46
4.3.10.0230.39066.44
4.3.00.0370.44066.52

preferences:
40.06 ms | 400 KiB | 5 Q