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)
5.4.270.0050.04012.37
5.4.260.0070.04212.37
5.4.250.0070.03612.37
5.4.240.0070.03512.37
5.4.230.0090.04212.37
5.4.220.0090.04212.36
5.4.210.0070.04112.37
5.4.200.0080.03812.37
5.4.190.0070.03712.36
5.4.180.0070.04112.36
5.4.170.0110.04112.37
5.4.160.0070.04212.37
5.4.150.0100.03712.36
5.4.140.0080.04012.05
5.4.130.0060.03912.03
5.4.120.0050.03812.00
5.4.110.0070.03811.99
5.4.100.0100.03911.99
5.4.90.0090.03611.99
5.4.80.0080.03812.00
5.4.70.0090.03311.99
5.4.60.0050.03611.99
5.4.50.0090.03511.99
5.4.40.0050.04211.98
5.4.30.0050.04111.97
5.4.20.0080.04211.97
5.4.10.0090.03711.97
5.4.00.0090.03911.46
5.3.280.0090.04212.71
5.3.270.0080.04712.72
5.3.260.0100.05612.72
5.3.250.0120.04112.72
5.3.240.0060.03912.72
5.3.230.0100.03612.71
5.3.220.0100.03612.68
5.3.210.0070.04212.68
5.3.200.0080.04112.68
5.3.190.0070.03912.68
5.3.180.0080.03612.67
5.3.170.0070.03812.67
5.3.160.0070.03612.67
5.3.150.0060.03912.67
5.3.140.0070.03712.66
5.3.130.0040.04312.66
5.3.120.0070.04712.66
5.3.110.0090.03812.66
5.3.100.0040.03912.12
5.3.90.0040.03912.08
5.3.80.0090.03912.08
5.3.70.0050.04112.08
5.3.60.0080.04112.06
5.3.50.0090.04312.00
5.3.40.0110.04612.00
5.3.30.0090.04311.94
5.3.20.0060.04511.71
5.3.10.0080.03411.68
5.3.00.0040.04411.67

preferences:
135.74 ms | 1394 KiB | 7 Q