3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Behaves like a PHP array (unstructured) */ class Bag implements IteratorAggregate, ArrayAccess { private $__data; // Implementation for ArrayAccess public function offsetSet($offset, $value) { if (is_null($offset)) { $this->__data[] = value; } else { $this->__data[$offset] = $value; } } public function offsetExists($offset) { return isset($this->__data[$offset]); } public function offsetUnset($offset) { unset($this->__data[$offset]); } public function offsetGet($offset) { return isset($this->__data[$offset]) ? $this->__data[$offset] : null; } // Implementation for IteratorAggregate public function getIterator() { return new ArrayIterator($this->__data); } public function __construct(array $data) { $this->data = $data; } public function some(Closure $fn) { return new Bag(array_reduce($this->__data, function ($carry, $x) { return $fn($x) || $carry; }, false)); } public function every(Closure $fn) { return new Bag(array_reduce($this->__data, function ($carry, $x) { return $fn($x) && $carry; }, true)); } public function reduce(Closure $fn) { return new Bag(array_reduce($this->__data, $fn)); } public function map(Closure $fn) { return new Bag(array_map($fn, $this->__data)); } public function filter(Closure $fn) { return new Bag(array_filter($this->__data, $fn)); } } $bag = new Bag([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); print_r($bag->filter(function ($x) { return !($x % 2); }));

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.5.10.0070.00720.27
8.5.00.0110.01020.22
8.4.150.0020.00014.05
8.4.140.0160.00617.85
8.4.130.0080.01217.91
8.4.120.0150.00520.41
8.4.110.0110.01018.87
8.4.100.0140.00717.85
8.4.90.0140.00718.21
8.4.80.0130.00819.70
8.4.70.0110.00918.09
8.4.60.0070.01418.43
8.4.50.0110.00818.92
8.4.40.0130.00719.52
8.4.30.0060.00318.03
8.4.20.0030.01317.64
8.4.10.0030.00617.96
8.3.280.0020.00114.05
8.3.270.0150.00516.75
8.3.260.0100.00816.96
8.3.250.0110.01019.16
8.3.240.0080.00316.78
8.3.230.0050.00416.69
8.3.220.0100.00916.79
8.3.210.0020.00616.75
8.3.200.0050.00416.66
8.3.190.0120.00620.83
8.3.180.0100.00817.32
8.3.170.0030.01518.86
8.3.160.0090.00916.72
8.3.150.0040.01517.20
8.3.140.0000.01216.71
8.3.130.0030.00618.43
8.3.120.0120.00620.63
8.3.110.0060.00920.94
8.3.100.0090.00024.06
8.3.90.0040.00426.77
8.3.80.0030.01017.97
8.3.70.0060.00916.63
8.3.60.0000.01518.43
8.3.50.0140.00522.00
8.3.40.0110.00718.92
8.3.30.0110.00319.22
8.3.20.0040.00420.39
8.3.10.0040.00421.83
8.3.00.0040.00419.18
8.2.290.0110.00819.30
8.2.280.0110.00818.64
8.2.270.0090.00917.03
8.2.260.0060.00318.60
8.2.250.0060.00316.84
8.2.240.0060.00317.20
8.2.230.0040.00822.58
8.2.220.0080.00037.54
8.2.210.0060.00326.77
8.2.200.0030.00617.13
8.2.190.0070.00718.18
8.2.180.0120.00918.44
8.2.170.0070.01122.96
8.2.160.0070.00722.12
8.2.150.0000.00924.18
8.2.140.0070.00324.66
8.2.130.0040.00426.16
8.2.120.0060.00319.77
8.2.110.0000.00920.43
8.2.100.0080.00317.91
8.2.90.0030.00617.63
8.2.80.0050.00318.05
8.2.70.0080.00017.93
8.2.60.0050.00318.16
8.2.50.0050.00318.10
8.2.40.0040.00421.04
8.2.30.0040.00419.29
8.2.20.0000.00817.74
8.2.10.0000.00818.09
8.2.00.0030.00517.67
8.1.330.0140.00516.97
8.1.320.0110.00920.11
8.1.310.0030.00616.29
8.1.300.0070.01118.23
8.1.290.0030.00630.84
8.1.280.0160.00625.92
8.1.270.0040.00418.79
8.1.260.0000.00926.35
8.1.250.0080.00028.09
8.1.240.0100.00022.00
8.1.230.0030.00920.93
8.1.220.0110.00017.74
8.1.210.0090.00018.77
8.1.200.0030.00617.35
8.1.190.0050.00517.35
8.1.180.0040.00418.10
8.1.170.0040.00418.56
8.1.160.0000.00718.96
8.1.150.0070.00018.93
8.1.140.0050.00217.54
8.1.130.0000.00817.79
8.1.120.0070.00017.50
8.1.110.0040.00417.50
8.1.100.0000.00717.40
8.1.90.0020.00517.50
8.1.80.0030.00517.53
8.1.70.0070.00017.38
8.1.60.0030.00617.60
8.1.50.0030.00617.53
8.1.40.0040.00417.53
8.1.30.0060.00317.52
8.1.20.0050.00317.72
8.1.10.0000.00817.63
8.1.00.0000.00817.44
8.0.300.0070.00019.73
8.0.290.0000.00816.74
8.0.280.0070.00018.47
8.0.270.0030.00317.17
8.0.260.0030.00317.18
8.0.250.0020.00517.08
8.0.240.0050.00517.07
8.0.230.0030.00317.12
8.0.220.0070.00016.98
8.0.210.0050.00216.86
8.0.200.0000.00617.02
8.0.190.0090.00016.92
8.0.180.0000.00716.91
8.0.170.0000.00717.11
8.0.160.0000.00717.01
8.0.150.0000.00916.98
8.0.140.0030.00516.83
8.0.130.0060.00013.41
8.0.120.0040.00417.00
8.0.110.0000.00816.96
8.0.100.0000.00716.95
8.0.90.0040.00417.00
8.0.80.0060.00916.94
8.0.70.0040.00416.98
8.0.60.0040.00416.94
8.0.50.0000.00816.99
8.0.30.0140.00817.11
8.0.20.0060.01717.40
8.0.10.0050.00217.14
8.0.00.0100.00716.79
7.4.330.0030.00315.09
7.4.320.0040.00416.68
7.4.300.0060.00016.44
7.4.290.0030.00316.52
7.4.280.0040.00416.66
7.4.270.0040.00416.66
7.4.260.0040.00416.66
7.4.250.0000.00716.40
7.4.240.0040.00416.52
7.4.230.0000.00716.62
7.4.220.0060.01216.45
7.4.210.0030.01316.69
7.4.200.0070.00016.74
7.4.160.0100.00716.41
7.4.150.0140.00517.40
7.4.140.0100.00717.86
7.4.130.0040.01316.57
7.4.120.0090.00716.58
7.4.110.0120.00616.48
7.4.100.0150.00716.63
7.4.90.0100.01316.64
7.4.80.0090.01319.39
7.4.70.0130.01016.48
7.4.60.0100.00616.44
7.4.50.0040.00016.57
7.4.40.0060.01116.36
7.4.30.0090.00916.60
7.4.00.0040.00814.87
7.3.330.0000.00613.43
7.3.320.0000.00613.34
7.3.310.0080.00016.28
7.3.300.0030.00316.28
7.3.290.0050.00916.35
7.3.280.0110.00516.39
7.3.270.0100.00717.40
7.3.260.0000.01616.40
7.3.250.0080.00916.48
7.3.240.0130.00316.41
7.3.230.0040.01616.61
7.3.210.0060.01216.42
7.3.200.0130.00619.39
7.3.190.0150.00016.46
7.3.180.0060.01016.55
7.3.170.0070.01516.46
7.3.160.0080.00816.51
7.2.330.0070.01016.88
7.2.320.0070.01016.75
7.2.310.0090.01216.88
7.2.300.0070.01416.62
7.2.290.0030.01316.82
7.2.60.0000.01416.96
7.2.00.0030.00919.51
7.1.200.0090.00315.81
7.1.100.0070.00718.06
7.1.70.0070.00017.16
7.1.60.0070.01819.22
7.1.50.0070.01516.89
7.1.00.0100.07022.34
7.0.200.0000.00816.93
7.0.140.0000.07322.11
7.0.60.0070.08019.93
7.0.50.0170.07317.89
7.0.40.0030.05020.28
7.0.30.0170.05320.24
7.0.20.0270.04720.15
7.0.10.0070.08020.25
7.0.00.0070.08020.19
5.6.280.0030.07321.06
5.6.210.0000.04320.79
5.6.200.0030.08018.20
5.6.190.0100.04320.46
5.6.180.0370.06320.42
5.6.170.0170.05320.62
5.6.160.0070.06320.52
5.6.150.0100.07318.29
5.6.140.0000.04018.24
5.6.130.0030.08018.25
5.6.120.0070.03721.11
5.6.110.0100.05321.04
5.6.100.0030.09021.11
5.6.90.0030.08721.09
5.6.80.0070.08020.39
5.5.350.0230.08020.43
5.5.340.0170.07318.00
5.5.330.0100.07020.30
5.5.320.0230.05320.24
5.5.310.0300.04320.28
5.5.300.0130.07717.97
5.5.290.0100.03717.98
5.5.280.0100.07320.82
5.5.270.0130.06720.91
5.5.260.0070.04720.88
5.5.250.0170.07020.62
5.5.240.0100.07020.18
5.4.450.0170.05319.74
5.4.440.0770.06719.17
5.4.430.0400.05319.32
5.4.420.0430.07019.56
5.4.410.0500.06319.46
5.4.400.0630.05319.30
5.4.390.0730.05019.13
5.4.380.0170.05718.55
5.4.370.0270.04318.52
5.4.360.0230.04718.68
5.4.350.0200.05318.49
5.4.340.0200.07018.55
5.4.320.0330.05718.60
5.4.310.0330.05318.76
5.4.300.0300.06318.76
5.4.290.0230.05718.52
5.4.280.0170.05018.51
5.4.270.0270.04718.54
5.4.260.0230.05018.47
5.4.250.0170.06318.80
5.4.240.0230.06018.81
5.4.230.0370.05318.53
5.4.220.0200.06018.73
5.4.210.0070.06318.67
5.4.200.0230.06316.62
5.4.190.0230.04718.47
5.4.180.0330.04018.57
5.4.170.0330.05718.69
5.4.160.0300.05718.68
5.4.150.0300.05718.46
5.4.140.0330.03716.28
5.4.130.0170.05016.38
5.4.120.0200.05016.23
5.4.110.0300.04016.46
5.4.100.0230.04716.28
5.4.90.0200.04716.29
5.4.80.0230.04316.44
5.4.70.0200.04716.32
5.4.60.0100.05316.31
5.4.50.0170.05316.19
5.4.40.0130.06316.24
5.4.30.0300.04316.26
5.4.20.0200.05016.27
5.4.10.0200.05316.24
5.4.00.0170.05015.88
5.3.290.0230.05014.80
5.3.280.0170.05714.76
5.3.270.0230.05714.75
5.3.260.0170.05314.70
5.3.250.0270.05714.77
5.3.240.0270.06014.77
5.3.230.0300.05314.84
5.3.220.0230.06314.61
5.3.210.0230.06714.59
5.3.200.0300.05314.64
5.3.190.0230.06014.71
5.3.180.0200.06314.73
5.3.170.0170.06714.80
5.3.160.0300.05714.68
5.3.150.0170.06014.67
5.3.140.0230.04014.65
5.3.130.0230.04714.60
5.3.120.0100.06014.66
5.3.110.0170.05714.60
5.3.100.0300.04014.14
5.3.90.0130.05314.04
5.3.80.0200.05714.05
5.3.70.0130.06014.09
5.3.60.0100.06314.10
5.3.50.0170.05314.04
5.3.40.0200.05014.09
5.3.30.0130.05313.97
5.3.20.0200.05713.89
5.3.10.0200.04713.79
5.3.00.0070.06313.72
5.2.170.0200.04011.16
5.2.160.0170.04311.20
5.2.150.0130.04311.16
5.2.140.0170.04011.25
5.2.130.0170.03711.19
5.2.120.0130.04011.19
5.2.110.0200.03711.14
5.2.100.0130.04011.22
5.2.90.0100.04311.19
5.2.80.0170.03711.14
5.2.70.0100.04711.15
5.2.60.0130.04011.17
5.2.50.0130.04311.14
5.2.40.0170.03311.01
5.2.30.0130.04711.20
5.2.20.0200.03711.20
5.2.10.0170.04310.90
5.2.00.0100.04710.75
5.1.60.0070.04710.04
5.1.50.0070.04710.12
5.1.40.0200.03710.11
5.1.30.0070.05010.46
5.1.20.0170.03310.47
5.1.10.0100.03710.20
5.1.00.0070.04010.11
5.0.50.0100.0278.58
5.0.40.0130.0208.41
5.0.30.0070.0438.27
5.0.20.0070.0278.34
5.0.10.0070.0308.37
5.0.00.0130.0438.20
4.4.90.0100.0177.19
4.4.80.0070.0207.19
4.4.70.0030.0277.19
4.4.60.0030.0237.19
4.4.50.0100.0177.19
4.4.40.0100.0307.19
4.4.30.0070.0207.19
4.4.20.0000.0277.19
4.4.10.0130.0137.19
4.4.00.0070.0337.19
4.3.110.0070.0277.19
4.3.100.0070.0207.19
4.3.90.0070.0207.19
4.3.80.0030.0437.19
4.3.70.0030.0237.19
4.3.60.0030.0237.19
4.3.50.0000.0277.19
4.3.40.0000.0407.19
4.3.30.0070.0207.19
4.3.20.0070.0207.19
4.3.10.0070.0207.19
4.3.00.0030.0207.63

preferences:
36.84 ms | 403 KiB | 5 Q