3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExtendedArrayObject extends ArrayObject { function offsetGet($offset) { echo "Called", PHP_EOL; return parent::offsetGet($offset, __FUNCTION__, $array); } } class ExtendedArrayAccess implements ArrayAccess { private $data = array(); function __construct(array $array = array()) { $this->data = $array; } function offsetExists($offset) { return array_key_exists($offset, $this->data); } function offsetGet($offset) { return $this->data[$offset]; } function offsetSet($offset, $value) { $this->data[$offset] = $value; } function offsetUnset($offset) { unset($this->data[$offset]); } } $inputs = array( 'array' => array(), 'ExtendedArrayObject' => new ExtendedArrayObject(), 'ExtendedArrayAccess' => new ExtendedArrayAccess(), ); class Tests { function test_existing_key_with_not_empty_value($array) { $array['foo'] = 1; $this->expect(isset($array['foo']) === true, __FUNCTION__, $array); $this->expect(empty($array['foo']) === false, __FUNCTION__, $array); } function test_existing_key_with_empty_value($array) { $array['foo'] = 0; $this->expect(isset($array['foo']) === true, __FUNCTION__, $array); $this->expect(empty($array['foo']) === true, __FUNCTION__, $array); } function test_non_existent_key($array) { $this->expect(isset($array['foo']) === true, __FUNCTION__, $array); $this->expect(empty($array['foo']) === false, __FUNCTION__, $array); } function test_existing_key_with_null_value($array) { $array['foo'] = null; $this->expect(isset($array['foo']) === false, __FUNCTION__, $array); $this->expect(empty($array['foo']) === true, __FUNCTION__, $array); } private function getType($v) { return is_array($v) ? 'array' : get_class($v); } private function expect($condition, $function, $array) { if (!$condition) { echo $this->getType($array), ' failed ', $function, PHP_EOL; } } } $tests = new Tests; foreach (get_class_methods($tests) as $test) { foreach ($inputs as $structure) { $tests->$test($structure); } }

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)
8.3.60.0130.00318.55
8.3.50.0160.00018.05
8.3.40.0150.00618.92
8.3.30.0090.00620.39
8.3.20.0040.00420.33
8.3.10.0080.00021.96
8.3.00.0060.00322.34
8.2.180.0090.01216.84
8.2.170.0040.01122.96
8.2.160.0100.00320.39
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0070.00726.16
8.2.120.0040.00419.95
8.2.110.0030.00622.12
8.2.100.0090.00317.91
8.2.90.0050.00319.17
8.2.80.0050.00319.28
8.2.70.0090.00217.63
8.2.60.0040.00418.05
8.2.50.0030.00618.07
8.2.40.0040.00418.28
8.2.30.0040.00718.07
8.2.20.0050.00217.66
8.2.10.0000.00917.84
8.2.00.0030.00617.75
8.1.270.0040.00424.66
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00323.66
8.1.230.0110.00019.15
8.1.220.0040.00417.74
8.1.210.0060.00318.77
8.1.200.0030.00717.35
8.1.190.0060.00317.63
8.1.180.0030.00619.14
8.1.170.0050.00318.70
8.1.160.0000.00722.08
8.1.150.0050.00318.66
8.1.140.0030.00617.46
8.1.130.0000.00717.81
8.1.120.0040.00417.52
8.1.110.0030.00517.42
8.1.100.0000.00717.48
8.1.90.0040.00417.42
8.1.80.0050.00317.42
8.1.70.0030.00317.47
8.1.60.0060.00317.59
8.1.50.0000.00817.48
8.1.40.0040.00417.53
8.1.30.0030.00617.57
8.1.20.0060.00317.67
8.1.10.0040.00417.46
8.1.00.0040.00417.42
8.0.300.0000.00818.77
8.0.290.0040.00417.04
8.0.280.0030.00418.47
8.0.270.0000.00717.25
8.0.260.0030.00316.81
8.0.250.0070.00017.09
8.0.240.0000.00717.04
8.0.230.0040.00416.93
8.0.220.0030.00616.97
8.0.210.0040.00416.96
8.0.200.0030.00317.04
8.0.190.0040.00417.02
8.0.180.0040.00417.01
8.0.170.0080.00016.94
8.0.160.0030.00416.84
8.0.150.0000.00716.90
8.0.140.0030.00617.00
8.0.130.0060.00013.36
8.0.120.0080.00016.89
8.0.110.0040.00417.00
8.0.100.0000.00716.80
8.0.90.0040.00416.98
8.0.80.0090.00617.04
8.0.70.0020.00516.92
8.0.60.0040.00417.05
8.0.50.0040.00416.86
8.0.30.0070.01117.16
8.0.20.0120.00917.42
8.0.10.0000.00817.20
8.0.00.0170.00516.86
7.4.330.0060.00015.11
7.4.320.0030.00316.63
7.4.300.0030.00316.65
7.4.290.0070.00016.46
7.4.280.0030.00316.52
7.4.270.0040.00316.54
7.4.260.0030.00313.30
7.4.250.0040.00416.54
7.4.240.0040.00416.63
7.4.230.0000.00716.73
7.4.220.0130.00616.70
7.4.210.0090.00916.54
7.4.200.0000.00716.55
7.4.190.0040.00416.43
7.4.160.0100.00716.41
7.4.150.0100.00917.40
7.4.140.0150.00617.86
7.4.130.0080.01116.68
7.4.120.0100.00816.58
7.4.110.0090.01516.52
7.4.100.0090.00916.44
7.4.90.0100.01016.61
7.4.80.0160.00019.39
7.4.70.0190.00316.50
7.4.60.0090.00916.59
7.4.50.0030.00616.59
7.4.40.0070.01022.77
7.4.30.0070.01116.46
7.4.00.0030.01115.16
7.3.330.0000.00513.42
7.3.320.0000.00513.31
7.3.310.0050.00316.50
7.3.300.0030.00316.41
7.3.290.0030.01316.39
7.3.280.0070.00816.48
7.3.270.0070.01017.40
7.3.260.0090.00916.46
7.3.250.0200.00416.66
7.3.240.0090.00916.49
7.3.230.0170.00316.67
7.3.210.0110.01116.45
7.3.200.0140.00319.39
7.3.190.0130.00416.30
7.3.180.0130.00516.45
7.3.170.0080.00816.49
7.3.160.0100.00716.50
7.3.120.0000.01814.93
7.2.330.0160.00416.62
7.2.320.0060.01216.69
7.2.310.0180.00616.77
7.2.300.0120.01116.54
7.2.290.0100.00716.58
7.2.00.0030.01019.57
7.1.100.0060.00818.29
7.1.70.0000.00817.36
7.1.60.0130.01319.43
7.1.50.0040.00716.92
7.1.00.0030.03322.35
7.0.200.0060.00616.87
7.0.140.0000.07022.15
7.0.100.0100.08020.16
7.0.90.0170.07319.90
7.0.80.0230.06019.88
7.0.70.0030.08019.91
7.0.60.0030.08319.91
7.0.50.0070.05320.19
7.0.40.0030.06720.15
7.0.30.0100.08020.00
7.0.20.0100.08320.09
7.0.10.0070.07719.90
7.0.00.0070.07719.90
5.6.280.0000.07721.05
5.6.250.0070.08020.58
5.6.240.0070.05320.49
5.6.230.0000.09020.58
5.6.220.0000.09020.59
5.6.210.0100.06320.44
5.6.200.0070.06721.02
5.6.190.0070.08020.91
5.6.180.0070.04021.12
5.6.170.0130.07021.03
5.6.160.0100.07321.02
5.6.150.0000.07021.16
5.6.140.0230.06720.93
5.6.130.0100.07021.06
5.6.120.0070.07721.03
5.6.110.0100.08320.91
5.6.100.0130.05320.92
5.6.90.0100.07721.08
5.6.80.0030.05320.48
5.6.70.0000.08720.37
5.6.60.0070.08020.37
5.6.50.0070.07720.54
5.6.40.0170.07720.45
5.6.30.0130.07320.30
5.6.20.0070.07720.38
5.6.10.0070.07020.38
5.6.00.0130.07720.25
5.5.380.0030.08320.43
5.5.370.0070.05020.48
5.5.360.0030.09020.36
5.5.350.0070.08020.47
5.5.340.0170.06720.84
5.5.330.0070.04020.77
5.5.320.0100.07320.79
5.5.310.0100.04020.86
5.5.300.0130.07320.78
5.5.290.0100.07720.79
5.5.280.0130.06720.92
5.5.270.0070.07720.89
5.5.260.0100.04320.81
5.5.250.0130.07720.60
5.5.240.0100.07020.23
5.5.230.0100.07320.19
5.5.220.0070.08020.10
5.5.210.0070.07020.28
5.5.200.0170.07020.23
5.5.190.0070.08020.14
5.5.180.0170.06320.14
5.5.160.0100.07020.23
5.5.150.0200.06720.20
5.5.140.0070.07720.23
5.5.130.0030.07320.11
5.5.120.0170.06720.21
5.5.110.0070.03720.26
5.5.100.0030.04719.97
5.5.90.0100.07720.05
5.5.80.0030.07020.00
5.5.70.0070.04320.13
5.5.60.0030.06020.04
5.5.50.0030.07319.92
5.5.40.0130.05720.04
5.5.30.0070.04020.14
5.5.20.0070.04020.05
5.5.10.0070.03720.09
5.5.00.0030.04020.13
5.4.450.0030.04019.47
5.4.440.0130.07019.45
5.4.430.0130.08319.29
5.4.420.0070.08019.50
5.4.410.0070.06019.33
5.4.400.0030.07019.10
5.4.390.0100.07719.10
5.4.380.0070.07319.03
5.4.370.0070.07719.02
5.4.360.0070.06019.21
5.4.350.0030.08318.85
5.4.340.0030.08019.14
5.4.320.0070.08019.16
5.4.310.0030.07718.95
5.4.300.0070.05719.21
5.4.290.0070.07319.04
5.4.280.0130.06719.04
5.4.270.0100.03319.16
5.4.260.0170.06019.05
5.4.250.0030.04719.16
5.4.240.0070.04718.84
5.4.230.0130.06318.91
5.4.220.0100.07318.91
5.4.210.0100.08718.93
5.4.200.0070.07719.24
5.4.190.0100.05018.89
5.4.180.0070.04019.12
5.4.170.0030.04019.13
5.4.160.0070.03719.02
5.4.150.0000.04719.16
5.4.140.0030.03716.39
5.4.130.0030.04016.47
5.4.120.0100.03016.46
5.4.110.0030.03316.45
5.4.100.0100.03016.38
5.4.90.0030.03716.33
5.4.80.0030.04716.55
5.4.70.0000.04016.48
5.4.60.0000.04016.37
5.4.50.0000.03716.32
5.4.40.0070.05316.46
5.4.30.0070.03316.41
5.4.20.0030.03316.49
5.4.10.0030.05016.48
5.4.00.0070.03315.84
5.3.290.0100.06714.73
5.3.280.0170.06714.77
5.3.270.0000.04314.66
5.3.260.0030.04014.71
5.3.250.0070.03314.74
5.3.240.0000.03714.71
5.3.230.0000.04714.66
5.3.220.0030.03714.75
5.3.210.0070.03314.54
5.3.200.0000.03714.56
5.3.190.0070.03714.56
5.3.180.0070.04314.61
5.3.170.0070.03714.67
5.3.160.0030.03714.70
5.3.150.0000.04014.67
5.3.140.0030.03314.53
5.3.130.0070.03314.73
5.3.120.0070.03714.61
5.3.110.0070.03314.57
5.3.100.0000.04014.03
5.3.90.0030.04014.03
5.3.80.0030.03714.06
5.3.70.0030.03713.98
5.3.60.0100.03014.10
5.3.50.0070.03014.09
5.3.40.0070.03714.09
5.3.30.0070.03314.07
5.3.20.0070.03313.82
5.3.10.0070.04013.81
5.3.00.0000.04013.70
5.2.170.0070.03011.25
5.2.160.0070.03011.22
5.2.150.0000.03311.18
5.2.140.0000.03711.05
5.2.130.0030.02711.27
5.2.120.0030.02711.07
5.2.110.0030.02711.18
5.2.100.0030.02711.17
5.2.90.0030.02711.23
5.2.80.0070.02311.20
5.2.70.0000.03011.19
5.2.60.0000.03011.22
5.2.50.0070.02710.99
5.2.40.0070.02711.11
5.2.30.0030.02711.06
5.2.20.0000.03010.95
5.2.10.0030.02710.93
5.2.00.0030.02710.87
5.1.60.0030.02310.05
5.1.50.0000.0539.89
5.1.40.0000.02310.02
5.1.30.0070.03010.54
5.1.20.0000.03010.52
5.1.10.0030.05310.12
5.1.00.0030.05010.22
5.0.50.0070.0338.39
5.0.40.0030.0408.26
5.0.30.0000.0538.30
5.0.20.0030.0478.28
5.0.10.0030.0438.23
5.0.00.0070.0578.29
4.4.90.0030.0138.15
4.4.80.0000.0178.15
4.4.70.0000.0178.15
4.4.60.0000.0178.15
4.4.50.0030.0138.15
4.4.40.0030.0238.15
4.4.30.0030.0178.15
4.4.20.0030.0138.15
4.4.10.0000.0308.15
4.4.00.0000.0508.15
4.3.110.0030.0338.15
4.3.100.0070.0308.15
4.3.90.0000.0238.15
4.3.80.0030.0378.15
4.3.70.0030.0208.15
4.3.60.0000.0338.15
4.3.50.0000.0378.15
4.3.40.0030.0278.15
4.3.30.0000.0178.15
4.3.20.0030.0338.15
4.3.10.0030.0378.15
4.3.00.0000.0338.15

preferences:
56.08 ms | 400 KiB | 5 Q