3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * PHP Array key exists */ $n = 1000; // First a test with a empty array $array = array(); $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = isset($array[$i++]); //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - isset(array[i]) on empty array \n"; $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = array_key_exists($i++, $array); //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - array_key_exists(array,i) on empty array \n"; $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = (bool)@$array[$i++]; //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - cast array[i] on empty array \n"; // Create test array $i = 0; $array = array(); while($i < $n) { $array[$i++] = true; } $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = isset($array[$i++]); //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - isset(array[i]) on full array \n"; $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = array_key_exists($i++, $array); //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - array_key_exists(array,i) on full array \n"; $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = (bool)@$array[$i++]; //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - cast array[i] on full array \n"; ?>

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.0040.01119.55
7.1.70.0030.00717.22
7.1.60.0070.01819.17
7.1.50.0230.01634.55
7.1.00.0070.06722.46
7.0.200.0000.01016.97
7.0.140.0070.07322.09
7.0.60.0070.07721.84
7.0.50.0100.06317.88
7.0.40.0070.04019.92
7.0.30.0330.03720.30
7.0.20.0270.04320.30
7.0.10.0130.03720.17
7.0.00.0130.08019.99
5.6.280.0100.07021.13
5.6.210.0100.08020.54
5.6.200.0100.06718.12
5.6.190.0000.08720.77
5.6.180.0330.07720.77
5.6.170.0230.05320.51
5.6.160.0000.05720.54
5.6.150.0170.07318.12
5.6.140.0130.05018.11
5.6.130.0030.08318.19
5.6.120.0030.08721.02
5.6.110.0070.08721.16
5.6.100.0100.06720.92
5.6.90.0130.03321.04
5.6.80.0130.07720.31
5.5.350.4430.03320.37
5.5.340.0100.08317.84
5.5.330.0000.09020.40
5.5.320.0500.06720.48
5.5.310.0370.06720.33
5.5.300.0070.07317.92
5.5.290.0030.05717.89
5.5.280.0100.04720.81
5.5.270.0130.07320.90
5.5.260.0170.07020.91
5.5.250.0130.07320.75
5.5.240.0000.04320.24
5.4.450.3670.03719.59
5.4.440.3730.03719.50
5.4.430.3930.03719.21
5.4.420.3800.03019.38
5.4.410.2070.04319.28
5.4.400.3700.03319.16
5.4.390.2400.03719.32
5.4.380.3270.04018.89
5.4.370.4530.03719.11
5.4.360.3630.03719.16
5.4.350.3400.04019.01
5.4.340.3830.03719.23
5.4.320.3430.05019.22
5.4.310.4200.03719.21
5.4.300.3570.04019.23
5.4.290.3800.04019.13
5.4.280.3930.03719.08
5.4.270.3930.03719.06
5.4.260.4470.03719.17
5.4.250.4230.04319.22
5.4.240.4430.03719.07
5.4.230.3700.04318.99
5.4.220.3600.04019.08
5.4.210.3800.04319.22
5.4.200.3870.03718.99
5.4.190.3570.04319.09
5.4.180.3930.03719.14
5.4.170.3700.04019.05
5.4.160.3570.03719.15
5.4.150.3530.04018.84
5.4.140.3730.03716.50
5.4.130.3270.04316.29
5.4.120.3530.03716.49
5.4.110.4230.04016.55
5.4.100.3670.03716.30
5.4.90.3670.04316.52
5.4.80.4170.04016.61
5.4.70.3900.03316.38
5.4.60.3630.03316.42
5.4.50.3570.03716.51
5.4.40.4200.04016.45
5.4.30.3670.03716.18
5.4.20.3770.03716.47
5.4.10.3670.04016.50
5.4.00.3770.03715.86
5.3.290.3900.03314.75
5.3.280.3800.03314.69
5.3.270.4030.03314.73
5.3.260.3730.04014.69
5.3.250.3800.03714.79
5.3.240.3630.03314.78
5.3.230.3770.03314.69
5.3.220.3570.03714.66
5.3.210.3570.03714.66
5.3.200.3870.03714.68
5.3.190.3830.04314.66
5.3.180.3700.04014.66
5.3.170.3730.03714.57
5.3.160.3870.03714.67
5.3.150.3700.04014.56
5.3.140.3970.04014.64
5.3.130.3870.04014.64
5.3.120.3900.04014.71
5.3.110.3930.04314.64
5.3.100.3930.03314.13
5.3.90.3870.03014.14
5.3.80.3370.04314.15
5.3.70.3870.03714.20
5.3.60.3530.04314.16
5.3.50.3530.03313.94
5.3.40.3770.03314.04
5.3.30.3930.03014.15
5.3.20.3830.04013.82
5.3.10.3870.04013.62
5.3.00.3530.04013.63
5.2.170.2430.03311.50
5.2.160.3200.03311.50
5.2.150.3100.03711.34
5.2.140.3100.03311.49
5.2.130.3170.03311.30
5.2.120.3170.03011.30
5.2.110.3000.03011.45
5.2.100.3100.03311.52
5.2.90.3230.03311.40
5.2.80.3270.03011.30
5.2.70.3270.03011.37
5.2.60.3200.03011.40
5.2.50.3700.03711.28
5.2.40.3170.02711.18
5.2.30.3000.03711.15
5.2.20.2570.03011.27
5.2.10.1730.03711.22
5.2.00.1230.03011.05
5.1.60.2570.03310.44
5.1.50.1570.02010.45
5.1.40.1870.02010.27
5.1.30.1870.02710.75
5.1.20.2170.02710.64
5.1.10.2070.02310.35
5.1.00.2300.02710.52
5.0.50.1200.0238.98
5.0.40.1200.0238.77
5.0.30.1230.0278.51
5.0.20.1300.0178.46
5.0.10.0930.0208.44
5.0.00.1230.0308.58
4.4.90.1400.0176.22
4.4.80.1400.0176.13
4.4.70.0900.0236.19
4.4.60.0470.0206.21
4.4.50.0830.0176.23
4.4.40.0930.0236.20
4.4.30.1200.0176.11
4.4.20.1200.0176.25
4.4.10.1200.0176.26
4.4.00.1270.0206.21
4.3.110.0930.0176.11
4.3.100.1200.0176.13
4.3.90.1230.0136.16
4.3.80.1170.0276.18
4.3.70.1170.0176.11
4.3.60.1070.0136.11
4.3.50.0900.0176.11
4.3.40.0900.0276.11
4.3.30.0330.0206.11
4.3.20.0600.0206.11
4.3.10.0600.0176.11
4.3.00.0130.0176.11

preferences:
38.78 ms | 401 KiB | 5 Q