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.10.1670.10062.11
7.3.00.0870.10962.38
7.2.130.0970.10162.23
7.2.120.1230.11861.85
7.2.110.1180.12062.51
7.2.100.1190.11362.70
7.2.90.0690.11663.15
7.2.80.0750.10763.01
7.2.70.0770.11662.93
7.2.60.0830.11863.12
7.2.50.0660.11062.85
7.2.40.0530.11563.07
7.2.30.0770.11663.16
7.2.20.0950.11263.08
7.2.10.2370.11562.90
7.2.00.1550.10663.43
7.1.250.0940.14361.44
7.1.70.0300.08463.44
7.1.60.0100.08463.66
7.1.50.0170.14463.08
7.1.00.0130.17368.50
7.0.200.0940.11150.71
7.0.140.0100.18368.18
7.0.60.0100.13365.17
7.0.50.0170.18363.14
7.0.40.0030.13723.67
7.0.30.0400.12323.58
7.0.20.0430.16323.75
7.0.10.0070.14023.72
7.0.00.0230.17023.71
5.6.280.0100.26370.31
5.6.210.0130.21369.93
5.6.200.0230.20367.40
5.6.190.0130.21369.72
5.6.180.3570.18369.53
5.6.170.0230.19069.63
5.6.160.0100.19069.59
5.6.150.0200.25367.29
5.6.140.0270.24367.37
5.6.130.0170.25067.35
5.6.120.0270.24770.26
5.6.110.0230.24770.25
5.6.100.0330.22370.29
5.6.90.0300.24370.37
5.6.80.0100.19769.70
5.5.350.0430.23769.73
5.5.340.0300.24367.23
5.5.330.0270.21069.53
5.5.320.0630.24369.33
5.5.310.0470.24069.47
5.5.300.0170.19067.21
5.5.290.0300.25367.21
5.5.280.0330.23370.10
5.5.270.0170.27070.06
5.5.260.0070.19369.91
5.5.250.0200.18069.97
5.5.240.4300.20069.33
5.4.450.0730.34068.46
5.4.440.1000.47068.52
5.4.430.0700.32768.30
5.4.420.0630.35068.80
5.4.410.0730.31068.49
5.4.400.0400.37367.83
5.4.390.0470.32067.73
5.4.380.1300.53067.93
5.4.370.0530.35767.80
5.4.360.0700.30367.93
5.4.350.0370.32367.93
5.4.340.0570.31067.96
5.4.320.0390.20761.73
5.4.310.0330.20361.72
5.4.300.0270.22761.72
5.4.290.0390.20161.72
5.4.280.0460.22961.62
5.4.270.0500.46068.05
5.4.260.0200.37068.04
5.4.250.0200.31768.14
5.4.240.0500.33068.04
5.4.230.0470.47768.04
5.4.220.0470.44367.91
5.4.210.0400.46768.08
5.4.200.0770.35368.14
5.4.190.0600.39368.20
5.4.180.0570.37768.11
5.4.170.0630.46367.93
5.4.160.0530.43368.14
5.4.150.0670.47068.09
5.4.140.0600.39765.65
5.4.130.0630.33365.71
5.4.120.0530.40065.51
5.4.110.0430.43065.66
5.4.100.0530.36765.59
5.4.90.0570.34365.68
5.4.80.0830.30765.49
5.4.70.0700.46765.83
5.4.60.0730.44765.67
5.4.50.0530.32365.82
5.4.40.0400.43765.47
5.4.30.0230.35065.77
5.4.20.0470.35065.76
5.4.10.0530.30365.80
5.4.00.0470.36065.27
5.3.290.0250.24661.18
5.3.280.0500.36362.93
5.3.270.0430.46363.04
5.3.260.0630.44363.07
5.3.250.0470.42362.98
5.3.240.0600.44063.07
5.3.230.0700.47063.14
5.3.220.0400.51363.07
5.3.210.0600.49763.04
5.3.200.0700.43762.90
5.3.190.0670.44062.89
5.3.180.0570.40762.99
5.3.170.0470.41363.04
5.3.160.0600.52363.03
5.3.150.0470.39762.94
5.3.140.0470.38763.04
5.3.130.0500.44762.89
5.3.120.0230.41062.68
5.3.110.0330.37062.98
5.3.100.0830.50762.36
5.3.90.0400.53362.49
5.3.80.0530.41762.28
5.3.70.0370.39362.41
5.3.60.0370.40362.33
5.3.50.0600.44762.21
5.3.40.0600.49062.20
5.3.30.0600.41362.16
5.3.20.0600.45761.96
5.3.10.0700.74061.90
5.3.00.0570.71061.91
5.2.170.0530.46757.60
5.2.160.0470.49757.70
5.2.150.0400.42057.65
5.2.140.0830.47357.55
5.2.130.0500.44057.38
5.2.120.0730.43357.56
5.2.110.0230.47757.50
5.2.100.0470.50057.76
5.2.90.0370.48057.77
5.2.80.0530.40357.68
5.2.70.0870.45357.68
5.2.60.0370.56757.46
5.2.50.0570.48057.39
5.2.40.0500.45357.51
5.2.30.0330.38757.42
5.2.20.0500.68357.57
5.2.10.0570.70357.54
5.2.00.0530.66357.33
5.1.60.0500.78071.85
5.1.50.0770.82371.95
5.1.40.0370.73771.78
5.1.30.0630.70072.32
5.1.20.0370.62372.10
5.1.10.0470.62071.76
5.1.00.0570.64071.72
5.0.50.0670.82370.23
5.0.40.0630.81770.03
5.0.30.0500.81070.02
5.0.20.0770.83069.86
5.0.10.0570.72369.85
5.0.00.0400.72369.90
4.4.90.0930.92367.83
4.4.80.0570.74767.85
4.4.70.0900.83067.84
4.4.60.0830.72767.68
4.4.50.0430.77767.74
4.4.40.0630.71367.87
4.4.30.0630.78367.69
4.4.20.0530.65367.86
4.4.10.0570.76767.91
4.4.00.0570.72767.80
4.3.110.0830.89067.63
4.3.100.0630.62767.71
4.3.90.0430.67067.65
4.3.80.0400.77367.65
4.3.70.0370.66367.65
4.3.60.0700.93067.70
4.3.50.0570.77067.88
4.3.40.0300.99367.82
4.3.30.0630.98366.63
4.3.20.0630.87366.63
4.3.10.0800.86366.62
4.3.00.0430.65766.55

preferences:
37.28 ms | 401 KiB | 5 Q