3v4l.org

run code in 300+ PHP versions simultaneously
<?php function prepare($num) { echo "preparing array with $num elements ... "; $array = array(); for ($i=0; $i<$num; $i++) { $array[uniqid('', true)] = true; } echo 'OK', PHP_EOL; return $array; } function test($num, $cycles, $tries) { echo "@cycles: ", $cycles, PHP_EOL; echo "@length: ", $num, PHP_EOL; echo "@tries: ", $tries, PHP_EOL; $array = prepare($num); $key = uniqid('', true); echo "array_key_exists: "; $times = array(); for ($j=0; $j<$tries; $j++) { $t = microtime(true); for($i = 0; $i < $cycles; $i++) { array_key_exists($key, $array); } $times[$j] = microtime(true) - $t; } printf('%0.4f second(s)'.PHP_EOL, array_sum($times)/$tries); echo "isset: "; $times = array(); for ($j=0; $j<$tries; $j++) { $t = microtime(true); for($i = 0; $i < $cycles; $i++) { isset($array[$key]); } $times[$j] = microtime(true) - $t; } printf('%0.4f second(s)'.PHP_EOL, array_sum($times)/$tries); } $cycles = 100000; $tries = 5; echo '----------------------', PHP_EOL; test(1000, $cycles, $tries); echo '----------------------', PHP_EOL; test(10000, $cycles, $tries); echo '----------------------', PHP_EOL; test(100000, $cycles, $tries); echo '----------------------', PHP_EOL;

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.0.01.3560.19841.53
5.6.160.0260.47330.38
5.6.150.0230.41230.56
5.6.140.0130.48330.53
5.6.130.0130.45430.68
5.6.120.0160.50530.61
5.6.110.0300.43930.41
5.6.100.0230.61830.34
5.6.90.0160.50430.52
5.6.80.0350.55230.42
5.6.70.0160.46830.26
5.6.60.0360.42930.42
5.6.50.0200.49130.36
5.6.40.0160.49430.40
5.6.30.0180.56730.45
5.6.20.0330.55130.23
5.6.10.0360.60830.38
5.6.00.0260.51130.63
5.5.300.0330.43927.00
5.5.290.0260.51127.14
5.5.280.0320.48027.22
5.5.270.0080.51527.05
5.5.260.0290.51726.94
5.5.250.0140.58627.38
5.5.240.0230.46727.26
5.5.230.0190.41427.37
5.5.220.0320.55727.46
5.5.210.0120.50227.33
5.5.200.0400.47627.36
5.5.190.0190.44927.13
5.5.180.0380.62727.16
5.5.170.0470.52430.68
5.5.160.0350.57026.99
5.5.150.0270.58227.20
5.5.140.0260.50027.45
5.5.130.0160.48927.45
5.5.120.0390.65227.23
5.5.110.0260.49827.33
5.5.100.0130.45727.10
5.5.90.0200.41527.32
5.5.80.0200.47427.38
5.5.70.0100.50627.36
5.5.60.0100.43027.39
5.5.50.0130.43027.32
5.5.40.0270.49626.91
5.5.30.0170.43627.16
5.5.20.0290.41527.43
5.5.10.0160.46127.37
5.5.00.0170.47227.35
5.4.450.0420.43927.23
5.4.440.0270.49627.48
5.4.430.0470.53027.05
5.4.420.0230.61326.97
5.4.410.0450.59026.96
5.4.400.0130.45227.27
5.4.390.0260.49727.61
5.4.380.0160.43827.42
5.4.370.0320.56627.29
5.4.360.0310.48027.42
5.4.350.0360.53527.47
5.4.340.0300.51227.50
5.4.330.0290.43527.10
5.4.320.0250.50727.08
5.4.310.0420.50227.21
5.4.300.0230.47327.29
5.4.290.0230.65527.18
5.4.280.0260.62226.97
5.4.270.0200.62127.18
5.4.260.0100.51227.39
5.4.250.0130.56727.43
5.4.240.0300.58527.41
5.4.230.0160.41327.17
5.4.220.0290.41927.27
5.4.210.0200.51127.17
5.4.200.0160.41327.32
5.4.190.0330.44827.46
5.4.180.0260.42227.23
5.4.170.0150.61927.12
5.4.160.0200.53227.28
5.4.150.0200.47127.39
5.4.140.0200.47327.28
5.4.130.0360.47127.34
5.4.120.0230.52827.63
5.4.110.0260.55527.30
5.4.100.0230.55527.27
5.4.90.0160.50027.01
5.4.80.0230.45827.51
5.4.70.0230.46927.06
5.4.60.0100.45727.10
5.4.50.0300.47227.36
5.4.40.0160.58527.32
5.4.30.0200.46027.29
5.4.20.0100.42927.20
5.4.10.0190.39927.20
5.4.00.0100.51127.25
5.3.290.0200.64326.66
5.3.280.0030.53026.45
5.3.270.0270.57226.38
5.3.260.0220.60926.59
5.3.250.0260.58626.63
5.3.240.0200.66326.50
5.3.230.0260.49126.26
5.3.220.0160.52626.46
5.3.210.0130.52626.39
5.3.200.0160.72626.53
5.3.190.0130.56826.63
5.3.180.0290.64626.66
5.3.170.0100.59826.53
5.3.160.0130.56526.54
5.3.150.0260.52226.70
5.3.140.0290.46926.63
5.3.130.0260.56126.64
5.3.120.0200.46526.69
5.3.110.0160.47426.61
5.3.100.0070.51626.64
5.3.90.0300.49326.61
5.3.80.0400.52526.60
5.3.70.0130.58026.45
5.3.60.0200.51726.57
5.3.50.0030.57226.66
5.3.40.0160.62226.56
5.3.30.0060.49026.51
5.3.20.0130.54126.58
5.3.10.0190.49426.39
5.3.00.0360.50726.32
5.2.170.0180.74024.49
5.2.160.0230.59724.69
5.2.150.0360.62424.49
5.2.140.0130.70224.61
5.2.130.0200.63124.63
5.2.120.0200.56124.71
5.2.110.0100.56124.75
5.2.100.0300.56424.68
5.2.90.0170.74824.60
5.2.80.0300.59724.57
5.2.70.0230.55224.54
5.2.60.0200.66224.20
5.2.50.0150.55424.56
5.2.40.0300.68924.63
5.2.30.0320.76324.57
5.2.20.0130.57224.55
5.2.10.0100.59624.52
5.2.00.0130.67424.45
5.1.60.0400.67927.63
5.1.50.0100.53127.29
5.1.40.0300.53027.39
5.1.30.0260.49727.71
5.1.20.0170.61027.41
5.1.10.0190.62127.77
5.1.00.0380.59227.24
5.0.50.0160.98326.55
5.0.40.0261.13526.20
5.0.30.0270.96726.38
5.0.20.0261.06726.17
5.0.10.0301.00826.25
5.0.00.0161.21826.29
4.4.90.0131.10024.25
4.4.80.0331.21724.53
4.4.70.0261.18724.42
4.4.60.0231.03124.28
4.4.50.0231.03224.31
4.4.40.0191.03324.41
4.4.30.0171.05224.37
4.4.20.0481.11924.55
4.4.10.0371.36324.38
4.4.00.0161.01824.21
4.3.110.0231.26624.27
4.3.100.0161.05524.16
4.3.90.0291.24724.27
4.3.80.0361.01724.18
4.3.70.0261.41724.10
4.3.60.0161.08324.12
4.3.50.0391.24324.20
4.3.40.0271.19324.33
4.3.30.0291.03223.57
4.3.20.0131.06123.50
4.3.10.0361.05823.61
4.3.00.0171.16123.67

preferences:
42.87 ms | 403 KiB | 5 Q