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.0040.01118.31
8.3.50.0070.00718.16
8.3.40.0090.00618.97
8.3.30.0100.00319.07
8.3.20.0050.00320.20
8.3.10.0020.00521.89
8.3.00.0080.00019.18
8.2.180.0150.00618.18
8.2.170.0090.00922.96
8.2.160.0070.00722.03
8.2.150.0030.00524.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0060.00319.66
8.2.110.0100.00721.09
8.2.100.0080.00317.78
8.2.90.0030.00517.75
8.2.80.0000.00917.97
8.2.70.0040.00418.04
8.2.60.0040.00418.08
8.2.50.0030.00518.10
8.2.40.0040.00421.22
8.2.30.0000.00819.23
8.2.20.0050.00217.61
8.2.10.0000.00717.98
8.2.00.0040.00417.83
8.1.280.0120.00925.92
8.1.270.0090.00018.88
8.1.260.0030.00726.35
8.1.250.0050.00328.09
8.1.240.0060.00323.84
8.1.230.0070.00421.04
8.1.220.0000.00817.79
8.1.210.0000.00818.77
8.1.200.0040.00417.35
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0060.00318.47
8.1.160.0040.00418.96
8.1.150.0030.00519.00
8.1.140.0000.00817.49
8.1.130.0000.00717.88
8.1.120.0000.00717.55
8.1.110.0000.00817.44
8.1.100.0040.00417.50
8.1.90.0040.00417.52
8.1.80.0050.00317.49
8.1.70.0000.00817.55
8.1.60.0050.00517.64
8.1.50.0040.00417.52
8.1.40.0040.00417.55
8.1.30.0030.00617.55
8.1.20.0000.00717.67
8.1.10.0040.00417.54
8.1.00.0000.00717.41
8.0.300.0090.00020.11
8.0.290.0000.00816.88
8.0.280.0040.00418.41
8.0.270.0070.00017.37
8.0.260.0000.00717.31
8.0.250.0030.00317.07
8.0.240.0030.00617.04
8.0.230.0000.00717.07
8.0.220.0040.00416.96
8.0.210.0000.00816.93
8.0.200.0000.00617.07
8.0.190.0030.00617.13
8.0.180.0040.00417.03
8.0.170.0000.00717.04
8.0.160.0000.00817.11
8.0.150.0000.00716.90
8.0.140.0000.00716.96
8.0.130.0030.00313.39
8.0.120.0000.00916.97
8.0.110.0050.00316.98
8.0.100.0050.00216.95
8.0.90.0040.00416.99
8.0.80.0090.00617.04
8.0.70.0050.00317.00
8.0.60.0040.00417.00
8.0.50.0080.00016.95
8.0.30.0130.01417.06
8.0.20.0100.01017.40
8.0.10.0030.00516.98
8.0.00.0110.01016.69
7.4.330.0060.00015.03
7.4.320.0000.00616.67
7.4.300.0060.00016.69
7.4.290.0030.00316.56
7.4.280.0040.00416.52
7.4.270.0080.00416.55
7.4.260.0030.00316.65
7.4.250.0040.00416.50
7.4.240.0020.00516.64
7.4.230.0030.00316.44
7.4.220.0150.00916.75
7.4.210.0030.01316.66
7.4.200.0000.00716.62
7.4.160.0150.00616.49
7.4.150.0120.00617.40
7.4.140.0090.01117.86
7.4.130.0070.01116.58
7.4.120.0110.00616.53
7.4.110.0090.00916.56
7.4.100.0090.00916.62
7.4.90.0130.00916.53
7.4.80.0000.01919.39
7.4.70.0070.01116.57
7.4.60.0110.00516.38
7.4.50.0060.00316.41
7.4.40.0090.00916.52
7.4.30.0110.00616.62
7.4.00.0030.00715.12
7.3.330.0050.00013.28
7.3.320.0060.00013.15
7.3.310.0030.00316.38
7.3.300.0030.00316.21
7.3.290.0040.00916.29
7.3.280.0110.00616.34
7.3.270.0060.01617.40
7.3.260.0100.00716.69
7.3.250.0090.01116.44
7.3.240.0100.00716.69
7.3.230.0100.00616.39
7.3.210.0090.01216.53
7.3.200.0100.00719.39
7.3.190.0130.00316.69
7.3.180.0000.01716.63
7.3.170.0090.00616.54
7.3.160.0100.00716.41
7.2.330.0070.01016.80
7.2.320.0110.00616.47
7.2.310.0100.01016.59
7.2.300.0120.00816.92
7.2.290.0130.01016.81
7.2.60.0800.00814.95
7.2.00.0070.00719.37
7.1.200.0060.00615.90
7.1.100.0000.01318.11
7.1.70.0030.00317.26
7.1.60.0100.01319.22
7.1.50.0210.00734.77
7.1.00.0070.07322.28
7.0.200.0050.01314.93
7.0.140.0030.04722.12
7.0.60.0030.07319.89
7.0.50.0100.08317.91
7.0.40.0200.07320.26
7.0.30.0270.07720.33
7.0.20.0200.04020.12
7.0.10.0070.05020.25
7.0.00.0070.07020.02
5.6.280.0130.06720.80
5.6.210.0070.04320.58
5.6.200.0170.07018.27
5.6.190.0130.07720.50
5.6.180.0330.04020.61
5.6.170.0170.04020.51
5.6.160.0100.06020.48
5.6.150.0100.07718.19
5.6.140.0100.03318.19
5.6.130.0030.05018.13
5.6.120.0030.04020.92
5.6.110.0100.08721.10
5.6.100.0070.09021.01
5.6.90.0070.08321.00
5.6.80.0100.07020.39
5.5.350.0300.06720.32
5.5.340.0030.06717.99
5.5.330.0030.05320.47
5.5.320.0330.07720.38
5.5.310.0330.07320.24
5.5.300.0170.07017.97
5.5.290.0030.04017.99
5.5.280.0070.04020.91
5.5.270.0130.06020.98
5.5.260.0230.06020.88
5.5.250.0070.05720.63
5.5.240.0070.07320.18
5.4.450.0200.07019.62
5.4.440.0530.05719.61
5.4.430.0670.05019.47
5.4.420.0830.05319.29
5.4.410.0800.05319.57
5.4.400.0870.04319.30
5.4.390.0800.04719.26
5.4.380.0170.06018.49
5.4.370.0200.05318.77
5.4.360.0170.05318.72
5.4.350.0230.04718.60
5.4.340.0200.05718.74
5.4.320.0170.05718.80
5.4.310.0200.05318.75
5.4.300.0130.06318.60
5.4.290.0200.05018.70
5.4.280.0200.05018.70
5.4.270.0170.05318.59
5.4.260.0200.05018.51
5.4.250.0170.05318.75
5.4.240.0230.04718.77
5.4.230.0270.04018.53
5.4.220.0200.05318.76
5.4.210.0070.06318.69
5.4.200.0200.05016.80
5.4.190.0170.06318.58
5.4.180.0170.05718.73
5.4.170.0170.05718.79
5.4.160.0300.06018.66
5.4.150.0170.08018.59
5.4.140.0270.07016.30
5.4.130.0300.06016.45
5.4.120.0300.06716.29
5.4.110.0170.05716.36
5.4.100.0170.05316.25
5.4.90.0270.06316.36
5.4.80.0230.04716.43
5.4.70.0230.07016.27
5.4.60.0200.04716.32
5.4.50.0230.04316.21
5.4.40.0330.04716.20
5.4.30.0200.05016.21
5.4.20.0170.06016.19
5.4.10.0200.04316.29
5.4.00.0230.04315.75
5.3.290.0200.05314.76
5.3.280.0400.03014.73
5.3.270.0230.05014.62
5.3.260.0170.06314.75
5.3.250.0270.06014.86
5.3.240.0170.06714.67
5.3.230.0270.04714.77
5.3.220.0170.05314.83
5.3.210.0270.04314.64
5.3.200.0170.05014.63
5.3.190.0170.05714.64
5.3.180.0070.06314.62
5.3.170.0100.06314.70
5.3.160.0230.04714.66
5.3.150.0230.06314.65
5.3.140.0170.05714.76
5.3.130.0270.05314.73
5.3.120.0300.05014.77
5.3.110.0130.07314.71
5.3.100.0270.06714.11
5.3.90.0130.05714.12
5.3.80.0170.05314.07
5.3.70.0100.06014.15
5.3.60.0170.05014.08
5.3.50.0130.05314.06
5.3.40.0170.05014.02
5.3.30.0100.05314.11
5.3.20.0200.04713.93
5.3.10.0170.04713.80
5.3.00.0270.03713.70
5.2.170.0130.04011.28
5.2.160.0230.04711.18
5.2.150.0130.04311.27
5.2.140.0230.04011.21
5.2.130.0130.05311.12
5.2.120.0300.03311.13
5.2.110.0170.03711.23
5.2.100.0230.03011.23
5.2.90.0200.04011.34
5.2.80.0200.04011.21
5.2.70.0200.04011.11
5.2.60.0100.04711.09
5.2.50.0170.05011.11
5.2.40.0170.03711.03
5.2.30.0200.04011.02
5.2.20.0170.03311.16
5.2.10.0130.04310.93
5.2.00.0100.04310.80
5.1.60.0230.04010.05
5.1.50.0170.03010.14
5.1.40.0100.03710.20
5.1.30.0100.03710.37
5.1.20.0170.04010.47
5.1.10.0170.03310.30
5.1.00.0200.02710.11
5.0.50.0070.0308.64
5.0.40.0100.0278.63
5.0.30.0130.0408.35
5.0.20.0070.0278.32
5.0.10.0070.0278.29
5.0.00.0070.0438.25
4.4.90.0000.0277.19
4.4.80.0100.0207.19
4.4.70.0130.0207.19
4.4.60.0130.0277.19
4.4.50.0130.0237.19
4.4.40.0100.0307.19
4.4.30.0070.0207.19
4.4.20.0030.0277.19
4.4.10.0000.0277.19
4.4.00.0070.0337.19
4.3.110.0100.0207.19
4.3.100.0030.0277.19
4.3.90.0070.0207.19
4.3.80.0070.0337.19
4.3.70.0130.0137.19
4.3.60.0070.0277.19
4.3.50.0030.0237.19
4.3.40.0030.0377.19
4.3.30.0100.0177.19
4.3.20.0000.0277.19
4.3.10.0030.0237.19
4.3.00.0030.0337.63

preferences:
50.31 ms | 400 KiB | 5 Q