3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * PHP Array key exists */ $n = 1000000; // 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.4.10.0370.59348.08
7.4.00.0400.57047.96
7.3.130.0370.40947.65
7.3.120.0170.63747.62
7.3.110.0230.67047.55
7.3.100.0170.39647.79
7.3.90.0300.59947.59
7.3.80.0370.59047.76
7.3.70.0330.43747.98
7.3.60.0300.64047.54
7.3.50.0230.62847.37
7.3.40.0300.45347.77
7.3.30.0270.54447.73
7.3.20.0300.52050.29
7.3.10.0070.41650.35
7.3.00.0030.49550.34
7.2.260.0400.45848.12
7.2.250.0330.66548.08
7.2.240.0270.59747.79
7.2.230.0430.56148.19
7.2.220.0260.44948.18
7.2.210.0270.51047.94
7.2.200.0400.43347.82
7.2.190.0400.63947.43
7.2.180.0400.46747.59
7.2.170.0100.44047.78
7.2.160.0200.42447.82
7.2.150.0200.59450.78
7.2.140.3810.54350.87
7.2.130.0370.42150.95
7.2.120.0270.41250.86
7.2.110.0160.42050.82
7.2.100.0500.42450.85
7.2.90.0220.43751.00
7.2.80.0120.00411.99
7.2.70.0220.00012.00
7.2.60.0190.29016.72
7.2.50.0120.14616.95
7.2.40.0620.41050.86
7.2.30.0240.39450.74
7.2.20.0200.42350.96
7.2.10.0680.41650.60
7.2.00.0390.40850.91
7.1.330.0030.77949.71
7.1.320.0070.85449.77
7.1.310.0070.68049.84
7.1.300.0130.89849.73
7.1.290.0830.70249.70
7.1.280.0100.71149.71
7.1.270.0300.75349.23
7.1.260.0070.76649.60
7.1.250.1130.75149.95
7.1.240.0130.68149.43
7.1.230.0130.75549.82
7.1.220.0200.69149.91
7.1.210.0200.65850.00
7.1.200.0200.63949.72
7.1.190.0260.63649.92
7.1.180.0100.66549.83
7.1.170.0170.72649.57
7.1.160.0230.65049.52
7.1.150.0200.65249.84
7.1.140.0430.66649.77
7.1.130.0170.73349.87
7.1.120.0170.71049.70
7.1.110.0420.70050.02
7.1.100.0190.65849.93
7.1.90.0190.65249.73
7.1.80.0420.71849.88
7.1.70.0380.68049.57
7.1.60.0230.67549.84
7.1.50.0610.63549.97
7.1.40.0200.71049.83
7.1.30.0270.73349.68
7.1.20.0270.00414.96
7.1.10.0130.67749.70
7.1.00.0270.71649.50
7.0.330.0130.65449.63
7.0.320.0280.71849.48
7.0.310.0110.09615.32
7.0.300.0130.67349.59
7.0.290.0680.65149.45
7.0.280.0280.65449.41
7.0.270.0230.66149.36
7.0.260.0500.70249.46
7.0.250.0200.71049.52
7.0.240.0400.63649.25
7.0.230.0170.66849.61
7.0.220.0200.73149.47
7.0.210.0730.70949.50
7.0.200.0560.67349.50
7.0.190.0430.66449.66
7.0.180.0230.66349.20
7.0.170.0470.73449.29
7.0.160.0720.63749.54
7.0.150.0200.68649.38
7.0.140.0200.76449.44
7.0.130.0460.74649.57
7.0.120.0360.69949.46
7.0.110.0330.68649.53
7.0.100.0460.76049.46
7.0.90.0230.76849.50
7.0.80.0300.72449.64
7.0.70.0260.82449.54
7.0.60.0250.70949.29
7.0.50.0200.66749.71
7.0.40.0330.76947.63
7.0.30.0170.88647.61
7.0.20.0160.70647.52
7.0.10.0590.78747.36
7.0.00.0380.80147.61
5.6.400.0271.02978.77
5.6.390.0500.98879.44
5.6.380.0490.91079.39
5.6.370.0460.94979.39
5.6.360.0330.91879.25
5.6.350.0460.92178.69
5.6.340.0430.95179.25
5.6.330.0120.63114.45
5.6.320.0060.56214.39
5.6.310.0690.92679.14
5.6.300.0370.91879.46
5.6.290.0330.90325.04
5.6.280.0240.96779.32
5.6.270.0351.00379.16
5.6.260.0330.93679.44
5.6.250.0510.98638.16
5.6.240.0431.30779.43
5.6.230.0271.29379.27
5.6.220.0301.09978.96
5.6.210.0560.91078.92
5.6.200.0400.89479.15
5.6.190.0290.93179.18
5.6.180.0501.03579.23
5.6.170.0791.10978.87
5.6.160.0511.06179.03
5.6.150.0400.90779.06
5.6.140.0160.68814.47
5.6.130.0460.90779.23
5.6.120.0170.90814.73
5.6.110.0331.02678.82
5.6.100.0301.01679.36
5.6.90.0461.23579.04
5.6.80.0431.15479.32
5.6.70.0541.13879.17
5.6.60.0231.14679.26
5.6.50.0420.98378.94
5.6.40.0301.03079.28
5.6.30.0390.91278.90
5.6.20.0430.95979.14
5.6.10.0431.00778.95
5.6.00.0271.00479.25
5.5.50.0560.70975.50
5.5.40.0620.90275.47
5.5.30.0511.02775.54
5.5.20.0790.73575.42
5.5.10.0880.78575.92
5.5.00.0650.74875.73
5.4.210.0740.75675.73
5.4.200.0660.94375.63
5.4.190.0550.72775.55
5.4.180.0500.85375.52
5.4.170.0680.92375.41
5.4.160.0550.86375.75
5.4.150.0650.70575.90
5.4.140.0570.86375.52
5.4.130.0620.73975.92
5.4.120.0820.91075.54
5.4.110.0500.78375.81
5.4.100.0520.87075.70
5.4.90.0620.78875.50
5.4.80.0430.90575.57
5.4.70.0361.02575.80
5.4.60.0760.93775.57
5.4.50.0580.91075.60
5.4.40.0650.73775.68
5.4.30.0770.86875.70
5.4.20.0430.82775.60
5.4.10.0750.93475.77
5.4.00.0680.82275.74
5.3.270.0871.05073.72
5.3.260.0500.93673.63
5.3.250.0591.14573.79
5.3.240.0490.96173.61
5.3.230.0500.92873.50
5.3.220.0691.00173.82
5.3.210.0430.91473.81
5.3.200.0631.03773.77
5.3.190.0590.96673.84
5.3.180.0750.94273.93
5.3.170.0361.10573.93
5.3.160.0651.45573.85
5.3.150.0561.04973.80
5.3.140.0590.99873.90
5.3.130.0560.96673.90
5.3.120.0591.20473.66
5.3.110.0620.96373.93
5.3.100.0470.96873.94
5.3.90.0620.94473.61
5.3.80.0710.96173.53
5.3.70.0520.90373.68
5.3.60.0501.17873.53
5.3.50.0551.03273.71
5.3.40.0471.06073.62
5.3.30.0560.85073.70
5.3.20.0531.01173.53
5.3.10.0551.04873.27
5.3.00.0531.10873.18

preferences:
42.63 ms | 400 KiB | 5 Q