3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('KEYS', 1000); $a = array(); function fill(&$arr) { for ($i = 1; $i <= 10; $i++) { $arr['key-' . $i] = $i; } } *function read_key(&$arr) { for ($i = 1; $i <= KEYS; $i++) { for ($j = 1; $j <= 10; $i++) { //$v = $arr['key-' . $i]; } } } function for_each(&$arr) { for ($i = 1; $i <= 1000; $i++) { foreach ($arr as $key => $value) { //$v = $value; } } } fill($a); //read_key($a); for_each($a);

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.290.0200.07718.87
5.4.280.0170.06319.15
5.4.270.0130.05319.06
5.4.260.0130.06319.13
5.4.250.0270.06019.14
5.4.240.0170.05019.09
5.4.230.0270.04719.08
5.4.220.0270.06319.08
5.4.210.0200.07018.94
5.4.200.0200.07319.30
5.4.190.0270.06319.30
5.4.180.0170.07719.20
5.4.170.0230.07718.84
5.4.160.0270.06719.18
5.4.150.0300.06018.96
5.4.140.0300.05716.52
5.4.130.0130.04016.49
5.4.120.0330.06316.67
5.4.110.0230.07316.55
5.4.100.0200.07316.51
5.4.90.0330.05316.45
5.4.80.0300.06016.25
5.4.70.0200.06716.34
5.4.60.0300.06016.38
5.4.50.0230.05716.43
5.4.40.0230.06716.58
5.4.30.0270.06716.23
5.4.20.0170.07016.51
5.4.10.0300.06316.44
5.4.00.0230.06715.84
5.3.280.0170.05314.82
5.3.270.0230.03714.76
5.3.260.0170.04314.69
5.3.250.0200.06714.65
5.3.240.0200.04014.52
5.3.230.0230.04314.57
5.3.220.0230.07714.54
5.3.210.0200.06314.57
5.3.200.0200.07014.54
5.3.190.0230.07714.48
5.3.180.0170.05714.78
5.3.170.0230.07714.55
5.3.160.0230.07314.61
5.3.150.0330.04714.47
5.3.140.0200.07714.67
5.3.130.0200.07014.60
5.3.120.0300.06714.71
5.3.110.0300.05714.52
5.3.100.0300.05713.95
5.3.90.0270.03014.13
5.3.80.0130.03713.92
5.3.70.0230.03013.93
5.3.60.0130.03713.91
5.3.50.0200.03013.87
5.3.40.0100.04013.89
5.3.30.0170.04013.82
5.3.20.0170.03013.61
5.3.10.0130.03313.66
5.3.00.0100.04013.66

preferences:
142.14 ms | 1394 KiB | 7 Q