3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); class Collection { private $_items; public function __construct(array $items = [])/*: void*/ { $this->_items = $items; } public function filter(callable $callback): self { foreach ($this->_items as $key => $value) if (!call_user_func($callback, $value)) unset($this->_items[$key]); return $this; } public function map(callable $callback): self { foreach ($this->_items as $key => $value) $this->_items[$key] = call_user_func($callback, $key, $value); return $this; } public function reindex(): self { $this->_items = array_values($this->_items); return $this; } public function sprintf(string $format): self { return $this->map(function ($key, $value) use ($format) { return substr_count($format, '%s') === 1 ? sprintf($format, $value) : sprintf($format, $key, $value); }); } public function keys(): self { $this->_items = array_keys($this->_items); return $this; } public function index($index): callable { return $this->map(function ($key, $value) use ($index) { return $value[$index]; }); } public function property(string $property): callable { return $this->map(function ($key, $value) use ($property) { return $value->$property; }); } public function implode(string $delimiter = ''): string { $output = ''; $first = TRUE; foreach ($this->_items as $value) if ($first) { $output .= $value; $first = FALSE; } else $output .= "$delimiter$value"; return $output; } public function values(): array { return $this->_items; } } class Filter { public static function not(callable $callback): callable { return function ($value) use ($callback) { return !call_user_func($callback, $value); }; } } echo (new Collection([ 42, 'one', 'two', ['foo' => 'BAR'], 'three', ['foo' => 'BAZ'], ])) ->filter(Filter::not('is_string')) ->filter('is_array') ->index('foo') ->reindex() //->keys() ->sprintf('(%s,%s)') ->implode('_');

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.0070.00717.00
8.3.50.0080.00616.59
8.3.40.0150.00018.79
8.3.30.0150.00018.96
8.3.20.0080.00020.22
8.3.10.0000.00823.42
8.3.00.0070.00023.66
8.2.180.0180.00416.88
8.2.170.0120.00322.96
8.2.160.0070.00720.52
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0080.00019.95
8.2.120.0070.00026.35
8.2.110.0030.00621.00
8.2.100.0110.00018.05
8.2.90.0080.00019.30
8.2.80.0000.00818.02
8.2.70.0000.01017.75
8.2.60.0040.00418.03
8.2.50.0000.00818.07
8.2.40.0060.00322.23
8.2.30.0040.00419.59
8.2.20.0040.00417.83
8.2.10.0030.00518.11
8.2.00.0030.00518.02
8.1.280.0140.01125.92
8.1.270.0080.00020.43
8.1.260.0030.00728.09
8.1.250.0050.00328.09
8.1.240.0060.00323.83
8.1.230.0120.00019.01
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0000.01017.35
8.1.190.0080.00417.35
8.1.180.0040.00418.10
8.1.170.0030.00618.65
8.1.160.0040.00420.84
8.1.150.0000.00818.92
8.1.140.0040.00419.61
8.1.130.0000.00717.61
8.1.120.0040.00417.53
8.1.110.0000.00717.40
8.1.100.0070.00017.50
8.1.90.0060.00317.51
8.1.80.0050.00317.49
8.1.70.0030.00317.51
8.1.60.0040.00417.63
8.1.50.0060.00317.61
8.1.40.0050.00517.57
8.1.30.0000.00817.73
8.1.20.0050.00317.67
8.1.10.0040.00417.57
8.1.00.0050.00317.52
8.0.300.0040.00418.77
8.0.290.0090.00016.75
8.0.280.0050.00318.47
8.0.270.0000.00717.29
8.0.260.0080.00017.29
8.0.250.0070.00016.95
8.0.240.0070.00317.09
8.0.230.0070.00017.04
8.0.220.0040.00416.97
8.0.210.0000.00716.96
8.0.200.0040.00417.05
8.0.190.0060.00316.98
8.0.180.0040.00417.02
8.0.170.0080.00016.90
8.0.160.0000.00717.02
8.0.150.0000.00716.99
8.0.140.0040.00416.82
8.0.130.0050.00313.41
8.0.120.0000.01016.98
8.0.110.0020.00517.02
8.0.100.0000.00716.88
8.0.90.0000.00716.85
8.0.80.0060.01617.02
8.0.70.0000.00816.88
8.0.60.0000.00716.93
8.0.50.0000.00716.77
8.0.30.0090.00717.19
8.0.20.0110.01317.40
8.0.10.0040.00417.07
8.0.00.0090.00916.96
7.4.330.0050.00016.77
7.4.320.0030.00316.57
7.4.300.0030.00316.49
7.4.290.0040.00416.62
7.4.280.0050.00516.43
7.4.270.0020.00516.61
7.4.260.0070.00016.46
7.4.250.0050.00316.59
7.4.240.0000.00716.67
7.4.230.0030.00316.59
7.4.220.0030.01616.67
7.4.210.0030.01416.59
7.4.200.0000.00716.38
7.4.160.0080.00816.70
7.4.150.0060.01217.40
7.4.140.0070.01317.86
7.4.130.0130.01016.55
7.4.120.0120.00916.45
7.4.110.0070.01416.52
7.4.100.0110.00716.56
7.4.90.0130.01016.71
7.4.80.0060.01019.39
7.4.70.0140.00716.51
7.4.60.0000.01816.64
7.4.50.0040.00816.35
7.4.40.0120.00616.29
7.4.30.0100.00716.57
7.4.00.0030.01514.87
7.3.330.0060.00013.39
7.3.320.0000.00513.31
7.3.310.0030.00316.43
7.3.300.0060.00016.43
7.3.290.0050.00216.34
7.3.280.0110.00616.45
7.3.270.0090.00917.40
7.3.260.0050.01516.46
7.3.250.0080.01316.52
7.3.240.0080.01016.57
7.3.230.0060.01116.47
7.3.210.0040.01916.39
7.3.200.0070.01019.39
7.3.190.0060.01616.46
7.3.180.0000.01616.70
7.3.170.0030.01516.49
7.3.160.0130.00316.38
7.3.120.0060.01214.61
7.3.110.0000.01314.86
7.3.100.0110.00314.61
7.3.90.0030.01215.06
7.3.80.0000.01414.95
7.3.70.0040.00414.74
7.3.60.0100.00314.73
7.3.50.0000.01314.57
7.3.40.0060.00614.71
7.3.30.0070.00714.75
7.3.20.0100.00716.61
7.3.10.0030.01216.63
7.3.00.0050.00516.55
7.2.330.0150.00316.44
7.2.320.0070.01016.97
7.2.310.0110.00816.84
7.2.300.0150.00816.67
7.2.290.0120.00516.59
7.2.250.0080.01215.25
7.2.240.0140.00715.06
7.2.230.0000.00915.11
7.2.220.0030.00915.18
7.2.210.0040.00715.08
7.2.200.0040.00815.13
7.2.190.0060.00915.14
7.2.180.0030.00915.09
7.2.170.0030.01315.27
7.2.60.0040.01116.86
7.2.00.0060.00619.38
7.1.330.0090.00615.57
7.1.320.0000.01315.74
7.1.310.0030.00515.33
7.1.300.0030.01015.43
7.1.290.0000.01415.83
7.1.280.0060.00915.96
7.1.270.0030.01415.98
7.1.260.0090.00615.88
7.1.200.0060.00915.56
7.1.100.0260.00617.18
7.1.70.0050.00217.09
7.1.60.0060.01919.30
7.1.50.0060.00617.12
7.1.00.0100.06322.35
7.0.200.0040.00416.68
7.0.60.0130.07721.66
7.0.50.0130.08017.93
7.0.40.0070.08320.11
7.0.30.0270.05020.34
7.0.20.0270.05320.10
7.0.10.0070.07320.25
7.0.00.0070.07020.12
5.6.280.0030.04721.08
5.6.210.0130.07320.65
5.6.200.0100.06318.15
5.6.190.0030.08720.43
5.6.180.0400.08020.48
5.6.170.0300.06320.52
5.6.160.0170.07320.39
5.6.150.0070.04318.15
5.6.140.0030.04718.28
5.6.130.0100.08018.23
5.6.120.0030.05020.97
5.6.110.0030.04021.02
5.6.100.0200.06320.96
5.6.90.0070.07321.13
5.6.80.0070.08320.51
5.5.350.4470.04720.45
5.5.340.0030.07718.05
5.5.330.0030.06020.18
5.5.320.0470.04720.27
5.5.310.0170.04020.26
5.5.300.0170.07017.98
5.5.290.0070.06317.97
5.5.280.0070.05720.88
5.5.270.0200.07020.85
5.5.260.0130.07720.85
5.5.250.0100.08720.50
5.5.240.0270.06720.19

preferences:
37.48 ms | 400 KiB | 5 Q