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); 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.3.60.0060.01318.30
8.3.50.0080.01221.88
8.3.40.0100.00718.79
8.3.30.0170.00019.13
8.3.20.0040.00420.33
8.3.10.0080.00021.95
8.3.00.0040.00419.08
8.2.180.0120.00918.66
8.2.170.0090.00922.96
8.2.160.0030.01022.08
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0080.00019.41
8.2.110.0080.00319.27
8.2.100.0090.00319.57
8.2.90.0050.00317.68
8.2.80.0040.00418.04
8.2.70.0090.00017.93
8.2.60.0000.00817.90
8.2.50.0000.00818.22
8.2.40.0000.00820.64
8.2.30.0000.00819.37
8.2.20.0040.00417.87
8.2.10.0000.00818.04
8.2.00.0000.00717.79
8.1.280.0070.01425.92
8.1.270.0100.00718.92
8.1.260.0030.00726.35
8.1.250.0080.00028.09
8.1.240.0040.00423.97
8.1.230.0170.00020.71
8.1.220.0000.00817.79
8.1.210.0080.00018.77
8.1.200.0060.00717.47
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0000.00818.83
8.1.160.0040.00418.82
8.1.150.0080.00018.96
8.1.140.0000.00817.56
8.1.130.0070.00017.94
8.1.120.0050.00217.54
8.1.110.0030.00517.42
8.1.100.0000.00717.49
8.1.90.0000.00717.47
8.1.80.0000.00817.43
8.1.70.0070.00017.48
8.1.60.0080.00017.64
8.1.50.0040.00417.48
8.1.40.0000.00717.58
8.1.30.0040.00417.78
8.1.20.0030.00517.77
8.1.10.0050.00317.53
8.1.00.0000.00817.41
8.0.300.0040.00419.69
8.0.290.0070.00017.00
8.0.280.0000.00718.50
8.0.270.0050.00316.93
8.0.260.0070.00017.27
8.0.250.0000.00717.08
8.0.240.0060.00317.06
8.0.230.0070.00016.94
8.0.220.0080.00017.00
8.0.210.0040.00417.01
8.0.200.0030.00316.98
8.0.190.0040.00417.13
8.0.180.0040.00417.00
8.0.170.0000.00717.11
8.0.160.0000.00717.02
8.0.150.0060.00316.95
8.0.140.0050.00316.86
8.0.130.0030.00313.51
8.0.120.0060.00316.96
8.0.110.0040.00417.08
8.0.100.0050.00216.82
8.0.90.0040.00417.12
8.0.80.0070.01416.96
8.0.70.0000.00716.77
8.0.60.0050.00316.89
8.0.50.0040.00416.85
8.0.30.0120.00917.30
8.0.20.0090.01017.40
8.0.10.0000.00717.00
8.0.00.0090.01216.94
7.4.330.0030.00315.03
7.4.320.0000.00716.54
7.4.300.0030.00316.64
7.4.290.0070.00016.56
7.4.280.0070.00016.55
7.4.270.0070.00316.65
7.4.260.0040.00416.68
7.4.250.0070.00016.52
7.4.240.0000.00816.58
7.4.230.0000.00716.43
7.4.220.0090.00916.46
7.4.210.0110.00716.67
7.4.200.0030.00316.45
7.4.160.0140.00616.30
7.4.150.0120.00617.40
7.4.140.0120.00917.86
7.4.130.0090.01116.53
7.4.120.0070.01016.54
7.4.110.0110.00716.55
7.4.100.0100.00716.48
7.4.90.0130.01016.55
7.4.80.0100.01119.39
7.4.70.0150.00916.65
7.4.60.0130.00316.47
7.4.50.0000.00416.77
7.4.40.0150.00616.58
7.4.30.0060.00916.72
7.4.10.0080.00815.13
7.4.00.0070.00915.07
7.3.330.0020.00213.16
7.3.320.0050.00013.22
7.3.310.0030.00316.36
7.3.300.0070.00016.38
7.3.290.0110.00316.38
7.3.280.0080.01116.38
7.3.270.0140.00417.40
7.3.260.0090.00816.42
7.3.250.0110.00616.59
7.3.240.0130.00316.61
7.3.230.0080.00916.40
7.3.210.0030.01316.39
7.3.200.0090.01519.39
7.3.190.0150.00016.61
7.3.180.0040.01916.57
7.3.170.0130.00316.45
7.3.160.0030.01216.41
7.3.130.0090.00614.92
7.3.120.0030.01514.91
7.3.110.0070.01314.77
7.3.100.0100.00715.00
7.3.90.0070.01014.81
7.3.80.0080.00414.92
7.3.70.0030.01014.93
7.3.60.0040.01414.89
7.3.50.0070.00414.98
7.3.40.0030.00914.90
7.3.30.0060.00314.63
7.3.20.0030.00916.64
7.3.10.0040.01016.65
7.3.00.0060.00816.67
7.2.330.0180.00016.84
7.2.320.0060.01016.89
7.2.310.0100.01216.54
7.2.300.0100.01316.41
7.2.290.0110.01116.71
7.2.260.0070.01114.92
7.2.250.0090.00915.17
7.2.240.0000.01815.36
7.2.230.0060.00914.79
7.2.220.0040.01114.86
7.2.210.0000.01414.99
7.2.200.0100.00615.22
7.2.190.0040.01214.99
7.2.180.0030.01014.89
7.2.170.0070.00714.88
7.2.160.0060.01015.21
7.2.150.0030.00717.07
7.2.140.0000.00916.84
7.2.130.0070.00716.72
7.2.120.0120.00316.93
7.2.110.0080.00616.97
7.2.100.0060.00517.02
7.2.90.0070.00617.05
7.2.80.0030.01216.80
7.2.70.0060.00916.93
7.2.60.0040.01117.00
7.2.50.0070.00716.86
7.2.40.0090.00316.81
7.2.30.0060.00916.96
7.2.20.0070.00816.75
7.2.10.0100.00516.92
7.2.00.0070.00917.85
7.1.330.0080.00315.63
7.1.320.0040.01515.62
7.1.310.0060.00915.86
7.1.300.0100.00315.45
7.1.290.0060.00615.69
7.1.280.0000.00815.91
7.1.270.0000.01215.67
7.1.260.0030.00715.76
7.1.250.0100.00515.69
7.1.240.0040.00415.63
7.1.230.0070.00315.60
7.1.220.0100.00715.95
7.1.210.0140.00015.52
7.1.200.0030.00915.54
7.1.190.0100.00315.78
7.1.180.0030.01015.59
7.1.170.0040.00415.76
7.1.160.0030.00615.90
7.1.150.0120.00315.67
7.1.140.0030.00715.52
7.1.130.0100.00315.79
7.1.120.0030.01015.80
7.1.110.0040.00816.00
7.1.100.0000.01116.85
7.1.90.0060.00915.52
7.1.80.0100.00015.61
7.1.70.0030.00616.42
7.1.60.0050.01217.37
7.1.50.0060.01016.24
7.1.40.0030.00715.59
7.1.30.0070.00715.68
7.1.20.0060.00915.71
7.1.10.0060.00315.66
7.1.00.0000.04519.08
7.0.330.0060.01015.43
7.0.320.0060.00615.21
7.0.310.0000.01415.56
7.0.300.0060.00315.37
7.0.290.0070.00715.43
7.0.280.0060.00915.35
7.0.270.0000.01315.48
7.0.260.0060.00915.38
7.0.250.0030.01015.43
7.0.240.0040.01115.52
7.0.230.0030.00915.46
7.0.220.0060.00315.40
7.0.210.0100.00615.05
7.0.200.0170.00715.99
7.0.190.0000.01115.51
7.0.180.0050.00315.48
7.0.170.0000.00815.57
7.0.160.0040.00715.27
7.0.150.0070.01015.37
7.0.140.0080.01818.62
7.0.130.0120.00315.29
7.0.120.0070.00715.36
7.0.110.0060.00315.31
7.0.100.0040.01215.11
7.0.90.0110.00415.52
7.0.80.0030.00615.43
7.0.70.0120.00015.21
7.0.60.0020.05117.58
7.0.50.0050.04716.56
7.0.40.0050.02916.83
7.0.30.0170.02416.75
7.0.20.0150.04716.89
7.0.10.0130.01916.79
7.0.00.0070.03516.79
5.6.400.0080.00414.73
5.6.390.0110.00314.48
5.6.380.0100.00014.46
5.6.370.0120.00314.34
5.6.360.0030.01014.52
5.6.350.0030.00714.31
5.6.340.0060.00914.31
5.6.330.0040.01414.51
5.6.320.0060.01014.39
5.6.310.0060.00914.43
5.6.300.0090.00614.26
5.6.290.0030.01014.67
5.6.280.0060.04017.68
5.6.270.0040.01114.41
5.6.260.0040.01114.39
5.6.250.0000.01414.43
5.6.240.0070.00714.37
5.6.230.0060.00914.24
5.6.220.0120.00614.46
5.6.210.0030.03917.59
5.6.200.0070.04416.16
5.6.190.0090.03917.52
5.6.180.0270.03717.70
5.6.170.0180.02317.41
5.6.160.0100.02017.42
5.6.150.0100.02216.32
5.6.140.0050.04416.17
5.6.130.0110.02616.26
5.6.120.0080.03417.66
5.6.110.0050.02917.74
5.6.100.0050.02317.77
5.6.90.0070.03617.65
5.6.80.0070.03517.35
5.6.70.0030.01414.43
5.6.60.0070.00714.22
5.6.50.0060.00614.18
5.6.40.0060.00914.53
5.6.30.0110.00714.22
5.6.20.0060.00914.13
5.6.10.0040.01214.48
5.6.00.0060.00914.03
5.5.380.0000.01014.22
5.5.370.0070.00714.13
5.5.360.0000.01514.03
5.5.350.0170.02617.28
5.5.340.0020.02716.28
5.5.330.0070.04217.37
5.5.320.0000.05217.44
5.5.310.0270.03517.43
5.5.300.0070.04416.14
5.5.290.0070.03116.23
5.5.280.0050.04517.53
5.5.270.0120.04417.54
5.5.260.0060.04617.50
5.5.250.0100.04017.53
5.5.240.0000.02417.35
5.5.230.0070.00714.16
5.5.220.0070.01014.35
5.5.210.0030.00714.32
5.5.200.0060.01014.38
5.5.190.0060.00614.11
5.5.180.0030.00614.06
5.5.170.0030.01314.36
5.5.160.0120.00014.40
5.5.150.0000.01314.16
5.5.140.0030.00914.11
5.5.130.0040.01514.48
5.5.120.0060.01014.28
5.5.110.0150.00014.23
5.5.100.0090.00614.16
5.5.90.0100.00314.48
5.5.80.0000.01614.33
5.5.70.0070.01014.14
5.5.60.0000.01714.34
5.5.50.0060.00313.84
5.5.40.0030.00914.37
5.5.30.0080.00414.23
5.5.20.0090.00014.43
5.5.10.0100.00714.33
5.5.00.0040.00813.93
5.4.450.0100.02215.54
5.4.440.0120.02815.45
5.4.430.0080.03315.53
5.4.420.0110.02315.57
5.4.410.0120.03115.46
5.4.400.0100.02715.29
5.4.390.0120.02015.40
5.4.380.0150.01815.34
5.4.370.0170.01515.26
5.4.360.0080.02515.40
5.4.350.0160.02015.21
5.4.340.0080.02815.32
5.4.330.0060.00611.58
5.4.320.0120.02815.29
5.4.310.0120.02315.23
5.4.300.0150.01715.44
5.4.290.0130.02015.37
5.4.280.0220.03715.22
5.4.270.0100.02315.26
5.4.260.0140.02615.30
5.4.250.0180.02015.21
5.4.240.0070.02415.36
5.4.230.0150.03815.40
5.4.220.0110.02315.37
5.4.210.0120.02215.35
5.4.200.0170.03215.38
5.4.190.0130.02315.35
5.4.180.0150.03715.37
5.4.170.0180.03715.38
5.4.160.0180.04015.27
5.4.150.0170.03515.44
5.4.140.0130.02213.99
5.4.130.0180.02214.02
5.4.120.0130.02613.99
5.4.110.0120.02213.95
5.4.100.0080.03314.11
5.4.90.0110.02014.07
5.4.80.0170.03014.04
5.4.70.0120.02614.09
5.4.60.0130.02314.05
5.4.50.0070.02614.03
5.4.40.0100.03713.92
5.4.30.0130.03014.00
5.4.20.0170.01814.01
5.4.10.0120.02313.98
5.4.00.0130.02513.72
5.3.290.0170.05314.72
5.3.280.0170.04314.64
5.3.270.0230.03714.70
5.3.260.0230.03314.56
5.3.250.0230.05714.62
5.3.240.0230.07014.70
5.3.230.0300.03714.72
5.3.220.0200.04714.72
5.3.210.0200.05014.51
5.3.200.0270.06014.58
5.3.190.0300.03714.72
5.3.180.0270.06314.53
5.3.170.0200.04314.62
5.3.160.0230.07014.48
5.3.150.0300.06014.50
5.3.140.0400.05314.74
5.3.130.0200.04714.59
5.3.120.0270.05014.67
5.3.110.0270.04014.61
5.3.100.0200.03014.00
5.3.90.0200.03714.04
5.3.80.0270.05714.07
5.3.70.0170.04314.17
5.3.60.0130.04314.09
5.3.50.0230.06313.99
5.3.40.0270.04314.08
5.3.30.0270.06013.86
5.3.20.0130.04013.64
5.3.10.0130.03313.85
5.3.00.0300.04713.75
5.2.170.0200.05711.24
5.2.160.0300.05711.07
5.2.150.0130.02711.07
5.2.140.0230.05711.14
5.2.130.0030.03311.27
5.2.120.0130.02711.03
5.2.110.0130.02711.02
5.2.100.0130.03011.23
5.2.90.0130.03011.20
5.2.80.0130.02711.02
5.2.70.0200.03011.11
5.2.60.0200.05710.99
5.2.50.0200.04310.94
5.2.40.0070.05010.99
5.2.30.0130.04310.94
5.2.20.0130.05310.95
5.2.10.0170.03310.83
5.2.00.0130.02710.78
5.1.60.0230.04310.76
5.1.50.0170.02010.76
5.1.40.0170.02710.76
5.1.30.0070.03010.76
5.1.20.0130.02710.76
5.1.10.0130.02310.76
5.1.00.0200.03310.76
5.0.50.0070.02310.76
5.0.40.0070.04310.76
5.0.30.0070.03010.76
5.0.20.0100.04310.76
5.0.10.0070.03310.76
5.0.00.0030.05710.76
4.4.90.0070.02310.76
4.4.80.0030.02010.76
4.4.70.0100.01710.76
4.4.60.0100.02310.76
4.4.50.0070.01310.76
4.4.40.0030.04310.76
4.4.30.0070.02310.76
4.4.20.0070.02010.76
4.4.10.0100.01710.76
4.4.00.0100.03310.76
4.3.110.0130.02310.76
4.3.100.0070.02010.76
4.3.90.0070.01310.76
4.3.80.0000.04310.76
4.3.70.0030.01710.76
4.3.60.0070.03010.76
4.3.50.0070.01710.76
4.3.40.0070.02310.76
4.3.30.0030.02310.76
4.3.20.0030.02010.76
4.3.10.0030.01710.76
4.3.00.0100.02310.76

preferences:
33.01 ms | 401 KiB | 5 Q