3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ringBuffer implements ArrayAccess { private $data; private $current = 0; public $size; public function __construct($sz=10) { $this->size = $sz; foreach(range(1, $sz) as $k=>$v) { /* s: whether this node is set; d: whether this node is "dirty" (has been read since it was last set); v: the value */ $this->data[$k] = array('s' => false, 'd' => false, 'v' => NULL); } } public function offsetGet($key) { if (! is_int($key)) $this->throwEx(array("offset '%s' must be an integer, not %s", $key, gettype($key))); if ($key > $this->size) $key %= $this->size; if (!isset($this->data[$key])) return false; if (!$this->data[$key]['s']) return false; $this->data[$key]['d'] = false; return $this->data[$key]['v']; } public function offsetExists($key) { if (! is_int($key)) throw new Exception(); if ($key > $this->size) return $this->data[$key]['s']; } public function offsetUnset($key) { $this->data[$key]['s'] = false; $this->data[$key]['v'] = NULL; } private function throwEx() { $args = func_get_args(); if (is_array($args0)) { $msg = call_user_func_array('sprintf', $args0); } throw new Exception($msg); } public function push($value) { if ($this->current >= $this->size) $this->current %= $this->size; $this->data[$this->current] = array('s'=>true, 'd'=>true, 'v' => $value); $this->current++; return $value; } } $a = new ringBuffer(2); $a->push("foo"); $a->push("bar"); $a->push("baz"); var_dump($a); /* Will throw an exception because you can't directly set indices in a ringBuffer */ $a0 = 'foo'; /* Will throw an exception because ringBuffer indices must be ints */ var_dump($a['foo']); var_dump($a[1.0]);

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.0140.00718.43
8.3.50.0070.01221.93
8.3.40.0120.00918.46
8.3.30.0150.00018.92
8.3.20.0040.00420.39
8.3.10.0040.00421.97
8.3.00.0030.00622.48
8.2.180.0110.01116.88
8.2.170.0110.00422.96
8.2.160.0100.00618.75
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00419.36
8.2.110.0060.00322.18
8.2.100.0090.00319.16
8.2.90.0000.00819.23
8.2.80.0080.00018.04
8.2.70.0080.00017.63
8.2.60.0040.00417.91
8.2.50.0060.00318.07
8.2.40.0080.00018.22
8.2.30.0000.00717.93
8.2.20.0050.00317.59
8.2.10.0000.00717.59
8.2.00.0080.00019.37
8.1.280.0110.00425.92
8.1.270.0080.00022.19
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0040.00423.97
8.1.230.0110.00018.92
8.1.220.0030.00517.74
8.1.210.0030.00618.77
8.1.200.0080.00317.23
8.1.190.0030.00517.30
8.1.180.0060.00318.10
8.1.170.0050.00318.71
8.1.160.0000.00721.97
8.1.150.0040.00418.54
8.1.140.0040.00417.32
8.1.130.0030.00317.79
8.1.120.0040.00417.34
8.1.110.0000.00717.34
8.1.100.0040.00417.34
8.1.90.0000.00717.36
8.1.80.0000.00717.47
8.1.70.0070.00017.35
8.1.60.0030.00717.59
8.1.50.0040.00417.52
8.1.40.0040.00417.41
8.1.30.0080.00017.42
8.1.20.0080.00017.53
8.1.10.0050.00317.39
8.1.00.0000.00817.23
8.0.300.0000.00718.77
8.0.290.0070.00017.16
8.0.280.0080.00018.32
8.0.270.0070.00017.26
8.0.260.0000.00716.74
8.0.250.0000.00716.86
8.0.240.0000.00816.95
8.0.230.0040.00416.86
8.0.220.0000.00816.79
8.0.210.0040.00416.89
8.0.200.0030.00316.86
8.0.190.0000.00716.98
8.0.180.0000.00716.82
8.0.170.0040.00416.95
8.0.160.0000.00716.90
8.0.150.0040.00416.90
8.0.140.0050.00216.93
8.0.130.0000.00713.34
8.0.120.0040.00416.84
8.0.110.0030.00516.92
8.0.100.0080.00016.87
8.0.90.0040.00416.71
8.0.80.0040.01316.97
8.0.70.0040.00416.89
8.0.60.0000.00716.86
8.0.50.0000.00716.93
8.0.30.0130.00617.10
8.0.20.0060.01317.40
8.0.10.0070.00017.10
8.0.00.0120.01116.68
7.4.330.0050.00015.13
7.4.320.0030.00316.52
7.4.300.0030.00316.61
7.4.290.0000.00816.59
7.4.280.0030.00316.40
7.4.270.0000.00716.55
7.4.260.0030.00316.57
7.4.250.0040.00416.36
7.4.240.0010.00616.52
7.4.230.0030.00516.45
7.4.220.0040.01516.59
7.4.210.0070.00816.54
7.4.200.0030.00316.36
7.4.190.0030.00316.42
7.4.160.0030.01216.41
7.4.150.0170.00717.40
7.4.140.0050.01717.86
7.4.130.0090.01016.52
7.4.120.0120.01116.37
7.4.110.0120.01616.51
7.4.100.0160.00616.48
7.4.90.0000.01716.38
7.4.80.0030.01419.39
7.4.70.0120.00616.38
7.4.60.0060.01016.54
7.4.50.0040.00416.26
7.4.40.0040.01522.77
7.4.30.0120.00416.51
7.4.10.0040.01515.10
7.4.00.0050.01115.01
7.3.330.0000.00513.24
7.3.320.0000.00513.34
7.3.310.0070.00016.25
7.3.300.0000.00716.25
7.3.290.0070.01116.25
7.3.280.0080.00816.25
7.3.270.0000.01717.40
7.3.260.0100.01016.31
7.3.250.0120.00716.42
7.3.240.0190.00416.18
7.3.230.0070.01116.51
7.3.210.0050.01416.43
7.3.200.0070.01019.39
7.3.190.0070.01316.55
7.3.180.0110.00416.42
7.3.170.0110.00516.40
7.3.160.0090.00616.35
7.3.130.0150.00014.92
7.3.120.0070.01114.66
7.3.110.0170.00314.83
7.3.100.0070.00414.89
7.3.90.0100.00314.79
7.3.80.0070.00715.11
7.3.70.0080.00414.86
7.3.60.0060.00614.77
7.3.50.0040.01114.70
7.3.40.0100.00314.55
7.3.30.0110.00314.79
7.3.20.0000.00916.42
7.3.10.0110.00316.50
7.3.00.0030.00816.40
7.2.330.0120.00416.59
7.2.320.0070.01616.59
7.2.310.0100.00716.31
7.2.300.0080.00816.24
7.2.290.0090.00916.54
7.2.260.0140.00414.94
7.2.250.0090.00915.18
7.2.240.0080.00814.85
7.2.230.0120.00615.02
7.2.220.0030.01714.66
7.2.210.0030.01414.87
7.2.200.0030.00815.09
7.2.190.0060.00614.84
7.2.180.0030.00715.08
7.2.170.0060.00315.09
7.2.160.0090.00614.84
7.2.150.0030.01016.54
7.2.140.0130.00016.90
7.2.130.0060.01116.86
7.2.120.0040.00816.84
7.2.110.0080.00416.79
7.2.100.0050.00816.89
7.2.90.0070.00816.86
7.2.80.0030.00716.90
7.2.70.0010.01316.68
7.2.60.0060.00816.86
7.2.50.0060.00816.67
7.2.40.0080.00316.90
7.2.30.0050.00916.79
7.2.20.0100.00516.83
7.2.10.0060.00816.81
7.2.00.0050.00716.75
7.1.330.0040.01115.74
7.1.320.0000.01115.63
7.1.310.0040.01215.68
7.1.300.0030.00715.68
7.1.290.0070.00715.70
7.1.280.0050.00315.64
7.1.270.0000.01215.85
7.1.260.0070.00715.66
7.1.250.0050.00615.69
7.1.240.0040.00715.39
7.1.230.0000.01615.64
7.1.220.0080.00415.71
7.1.210.0090.00315.60
7.1.200.0050.01015.61
7.1.190.0060.01015.57
7.1.180.0110.00315.50
7.1.170.0070.00415.59
7.1.160.0100.00315.28
7.1.150.0040.00815.70
7.1.140.0060.00615.54
7.1.130.0110.00015.67
7.1.120.0060.00615.78
7.1.110.0040.01215.55
7.1.100.0030.01216.63
7.1.90.0090.00615.85
7.1.80.0000.01515.36
7.1.70.0070.00416.40
7.1.60.0050.01517.79
7.1.50.0120.00516.25
7.1.40.0000.01115.34
7.1.30.0100.00615.53
7.1.20.0030.01015.75
7.1.10.0040.00815.55
7.1.00.0090.03518.89
7.0.330.0040.01114.96
7.0.320.0040.00715.16
7.0.310.0030.01315.06
7.0.300.0000.01315.23
7.0.290.0080.00015.06
7.0.280.0070.01015.48
7.0.270.0070.00715.38
7.0.260.0100.00315.11
7.0.250.0030.01015.41
7.0.240.0070.00315.23
7.0.230.0100.00315.36
7.0.220.0030.01215.10
7.0.210.0000.00915.44
7.0.200.0050.00816.06
7.0.190.0120.00315.46
7.0.180.0040.00715.16
7.0.170.0030.00815.34
7.0.160.0030.00715.45
7.0.150.0040.00715.40
7.0.140.0020.04118.72
7.0.130.0070.00415.22
7.0.120.0000.01115.46
7.0.110.0070.04217.63
7.0.100.0100.04317.70
7.0.90.0050.04817.73
7.0.80.0100.04317.70
7.0.70.0030.04917.71
7.0.60.0080.04117.72
7.0.50.0090.04217.88
7.0.40.0100.04216.60
7.0.30.0050.03916.75
7.0.20.0080.03616.77
7.0.10.0080.04216.78
7.0.00.0100.04516.64
5.6.400.0000.01114.46
5.6.390.0080.00814.16
5.6.380.0100.00014.32
5.6.370.0090.00614.17
5.6.360.0070.00714.16
5.6.350.0000.01014.33
5.6.340.0030.01314.29
5.6.330.0030.00914.14
5.6.320.0060.00314.30
5.6.310.0060.00613.94
5.6.300.0080.00814.27
5.6.290.0000.01213.93
5.6.280.0070.03817.68
5.6.270.0130.00014.00
5.6.260.0030.03017.48
5.6.250.0110.03617.23
5.6.240.0020.04917.54
5.6.230.0080.04717.43
5.6.220.0070.04217.39
5.6.210.0120.03817.28
5.6.200.0100.04317.58
5.6.190.0050.02617.60
5.6.180.0060.04217.54
5.6.170.0050.04017.62
5.6.160.0030.05217.47
5.6.150.0130.04317.54
5.6.140.0050.03017.62
5.6.130.0030.04117.66
5.6.120.0030.04217.73
5.6.110.0020.05117.59
5.6.100.0100.03717.67
5.6.90.0070.04517.60
5.6.80.0050.04217.14
5.6.70.0060.04317.26
5.6.60.0060.04017.47
5.6.50.0070.04317.13
5.6.40.0070.04317.14
5.6.30.0060.02817.18
5.6.20.0110.03817.17
5.6.10.0120.02717.27
5.6.00.0100.03617.35
5.5.380.0070.04317.32
5.5.370.0100.04117.27
5.5.360.0080.04317.39
5.5.350.0070.04317.15
5.5.340.0040.04317.64
5.5.330.0070.02817.33
5.5.320.0100.02717.64
5.5.310.0050.04217.63
5.5.300.0080.04417.62
5.5.290.0050.04817.49
5.5.280.0150.03817.46
5.5.270.0070.02717.45
5.5.260.0050.04817.53
5.5.250.0090.03817.33
5.5.240.0120.04217.19
5.5.230.0040.04716.92
5.5.220.0100.03517.29
5.5.210.0080.04217.20
5.5.200.0110.04017.22
5.5.190.0090.04017.14
5.5.180.0110.04117.32
5.5.170.0030.00913.79
5.5.160.0100.03717.07
5.5.150.0100.03817.27
5.5.140.0110.03717.17
5.5.130.0050.04517.08
5.5.120.0020.04717.07
5.5.110.0110.04117.10
5.5.100.0070.03816.97
5.5.90.0030.04617.11
5.5.80.0050.04017.09
5.5.70.0110.02616.92
5.5.60.0070.03717.12
5.5.50.0090.03817.02
5.5.40.0110.02816.83
5.5.30.0050.04417.03
5.5.20.0060.03617.08
5.5.10.0050.03216.99
5.5.00.0050.03316.95
5.4.450.0080.04415.04
5.4.440.0040.04215.04
5.4.430.0100.03515.32
5.4.420.0030.04614.98
5.4.410.0090.03414.99
5.4.400.0070.03614.88
5.4.390.0070.02314.81
5.4.380.0080.03714.76
5.4.370.0080.03714.99
5.4.360.0030.04315.17
5.4.350.0070.03315.05
5.4.340.0070.03815.14
5.4.330.0060.00610.55
5.4.320.0070.04214.95
5.4.310.0050.02514.86
5.4.300.0030.04215.06
5.4.290.0050.04014.91
5.4.280.0090.03814.93
5.4.270.0090.03714.85
5.4.260.0050.04315.12
5.4.250.0030.03814.98
5.4.240.0110.02314.93
5.4.230.0080.03815.12
5.4.220.0100.03714.99
5.4.210.0100.03515.08
5.4.200.0030.04315.14
5.4.190.0060.04214.90
5.4.180.0100.03314.81
5.4.170.0070.03414.77
5.4.160.0090.03714.98
5.4.150.0070.04115.00
5.4.140.0060.03713.42
5.4.130.0080.03513.64
5.4.120.0050.03913.41
5.4.110.0080.03813.56
5.4.100.0050.03813.67
5.4.90.0060.04013.67
5.4.80.0060.03013.76
5.4.70.0080.03513.72
5.4.60.0040.03413.73
5.4.50.0050.04113.44
5.4.40.0030.04113.74
5.4.30.0020.04013.67
5.4.20.0020.04413.69
5.4.10.0100.03713.52
5.4.00.0020.04013.29
5.3.290.0040.03412.63
5.3.280.0060.03812.50
5.3.270.0030.04412.53
5.3.260.0050.04112.45
5.3.250.0060.03512.45
5.3.240.0050.04412.50
5.3.230.0090.03612.47
5.3.220.0090.03612.50
5.3.210.0020.04312.51
5.3.200.0020.04312.47
5.3.190.0070.04212.46
5.3.180.0030.04112.56
5.3.170.0030.03812.55
5.3.160.0030.04212.47
5.3.150.0070.03812.59
5.3.140.0010.02912.48
5.3.130.0080.03812.53
5.3.120.0050.04312.50
5.3.110.0040.04112.46
5.3.100.0030.04012.29
5.3.90.0000.04412.24
5.3.80.0020.02712.23
5.3.70.0070.03312.15
5.3.60.0010.04012.19
5.3.50.0050.03212.13
5.3.40.0080.03812.17
5.3.30.0040.03912.15
5.3.20.0080.03712.01
5.3.10.0030.03712.05
5.3.00.0100.03511.96
5.2.170.0070.03311.88
5.2.160.0000.06711.88
5.2.150.0030.06311.88
5.2.140.0070.06311.88
5.2.130.0070.06011.88
5.2.120.0070.05011.88
5.2.110.0030.06011.88
5.2.100.0070.06011.88
5.2.90.0070.05011.88
5.2.80.0030.04311.88
5.2.70.0000.06711.88
5.2.60.0130.05311.88
5.2.50.0070.06011.88
5.2.40.0070.05311.88
5.2.30.0000.06011.88
5.2.20.0070.05311.88
5.2.10.0100.05311.88
5.2.00.0070.04711.88
5.1.60.0000.05311.88
5.1.50.0070.05311.88
5.1.40.0100.04711.88
5.1.30.0030.05011.88
5.1.20.0100.05311.88
5.1.10.0030.05311.88
5.1.00.0070.05311.88
5.0.50.0030.04011.88
5.0.40.0070.04011.88
5.0.30.0000.04011.88
5.0.20.0030.04311.88
5.0.10.0000.05011.88
5.0.00.0030.06311.88
4.4.90.0030.02711.88
4.4.80.0030.03311.88
4.4.70.0030.01711.88
4.4.60.0070.03011.88
4.4.50.0100.02011.88
4.4.40.0000.04711.88
4.4.30.0030.03311.88
4.4.20.0070.03011.88
4.4.10.0030.03311.88
4.4.00.0070.04711.88
4.3.110.0000.03711.88
4.3.100.0070.02711.88
4.3.90.0000.03011.88
4.3.80.0000.03311.88
4.3.70.0030.03011.88
4.3.60.0070.03011.88
4.3.50.0030.03311.88
4.3.40.0130.04011.88
4.3.30.0000.03711.88
4.3.20.0000.03711.88
4.3.10.0000.03711.88
4.3.00.0100.02711.88

preferences:
47.86 ms | 401 KiB | 5 Q