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 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 static function index($index): callable { return function ($key, $value) use ($index) { return $value[$index]; }; } public static function property(string $property): callable { return function ($key, $value) use ($property) { return $value->$property; }; } 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') ->map(Collection::index('bar')) ->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.0110.00718.58
8.3.50.0120.00316.63
8.3.40.0120.00918.96
8.3.30.0060.01318.85
8.3.20.0040.01220.39
8.3.10.0000.00823.56
8.3.00.0000.00823.48
8.2.180.0070.01016.63
8.2.170.0130.00918.96
8.2.160.0100.00722.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0090.00919.84
8.2.120.0080.00026.35
8.2.110.0050.00522.21
8.2.100.0040.00818.05
8.2.90.0080.00019.36
8.2.80.0000.00817.97
8.2.70.0000.00917.63
8.2.60.0060.00318.03
8.2.50.0050.00518.07
8.2.40.0000.00822.36
8.2.30.0040.00419.55
8.2.20.0030.00617.77
8.2.10.0000.00718.19
8.2.00.0000.00718.07
8.1.280.0120.00925.92
8.1.270.0090.00023.90
8.1.260.0030.00528.09
8.1.250.0080.00028.09
8.1.240.0040.00419.03
8.1.230.0080.00319.01
8.1.220.0040.00417.74
8.1.210.0000.00918.77
8.1.200.0060.00317.35
8.1.190.0030.00717.38
8.1.180.0040.00418.10
8.1.170.0030.00518.64
8.1.160.0070.00020.80
8.1.150.0060.00318.85
8.1.140.0000.00819.48
8.1.130.0000.00717.79
8.1.120.0000.00717.42
8.1.110.0080.00017.39
8.1.100.0000.00717.45
8.1.90.0040.00417.54
8.1.80.0000.00717.44
8.1.70.0040.00417.46
8.1.60.0000.00817.54
8.1.50.0000.00817.52
8.1.40.0080.00017.55
8.1.30.0000.00817.62
8.1.20.0040.00417.74
8.1.10.0060.00317.59
8.1.00.0000.01017.54
8.0.300.0070.00018.77
8.0.290.0050.00316.88
8.0.280.0040.00418.36
8.0.270.0030.00317.17
8.0.260.0000.00717.35
8.0.250.0000.00716.98
8.0.240.0030.00517.05
8.0.230.0070.00016.95
8.0.220.0040.00416.93
8.0.210.0000.00816.88
8.0.200.0030.00517.06
8.0.190.0080.00017.07
8.0.180.0000.00717.03
8.0.170.0050.00517.04
8.0.160.0030.00516.90
8.0.150.0040.00416.82
8.0.140.0040.00416.96
8.0.130.0050.00013.38
8.0.120.0050.00316.98
8.0.110.0000.00716.89
8.0.100.0080.00016.79
8.0.90.0050.00316.85
8.0.80.0110.00416.88
8.0.70.0030.00516.84
8.0.60.0040.00416.89
8.0.50.0000.00816.87
8.0.30.0100.00517.16
8.0.20.0100.00917.40
8.0.10.0050.00317.02
8.0.00.0120.00916.81
7.4.330.0020.00316.69
7.4.320.0030.00316.61
7.4.300.0000.00816.64
7.4.290.0030.00316.59
7.4.280.0090.00016.61
7.4.270.0030.00316.50
7.4.260.0070.00316.42
7.4.250.0000.00716.65
7.4.240.0020.00516.58
7.4.230.0000.00716.48
7.4.220.0120.00616.61
7.4.210.0090.00616.57
7.4.200.0030.00316.43
7.4.160.0120.00616.61
7.4.150.0080.01417.40
7.4.140.0120.00517.86
7.4.130.0080.00916.75
7.4.120.0100.00616.67
7.4.110.0030.01416.73
7.4.100.0090.01216.63
7.4.90.0120.00916.64
7.4.80.0110.00819.39
7.4.70.0170.00016.51
7.4.60.0070.01016.51
7.4.50.0030.01216.59
7.4.40.0070.01016.60
7.4.30.0080.01316.49
7.4.00.0030.01315.26
7.3.330.0060.00013.30
7.3.320.0050.00013.33
7.3.310.0000.00716.48
7.3.300.0030.00316.48
7.3.290.0070.00016.34
7.3.280.0070.01016.43
7.3.270.0140.00917.40
7.3.260.0030.01416.65
7.3.250.0110.00916.54
7.3.240.0080.01016.42
7.3.230.0090.00916.68
7.3.210.0060.01316.44
7.3.200.0070.02219.39
7.3.190.0060.01216.45
7.3.180.0130.00316.48
7.3.170.0100.00716.41
7.3.160.0120.01516.50
7.2.330.0170.00716.88
7.2.320.0110.00616.80
7.2.310.0070.01216.56
7.2.300.0070.01616.79
7.2.290.0140.00316.58
7.2.60.0100.00616.85
7.2.00.0000.01019.59
7.1.200.0070.00715.85
7.1.100.0070.01017.95
7.1.70.0060.00317.38
7.1.60.0070.01119.30
7.1.50.0030.00717.06
7.1.00.0030.07722.57
7.0.200.0030.00716.46
7.0.60.0270.07021.62
7.0.50.0000.05017.97
7.0.40.0130.08720.20
7.0.30.0300.07720.25
7.0.20.0370.05320.16
7.0.10.0070.05720.23
7.0.00.0030.07320.06
5.6.280.0030.06320.79
5.6.210.0030.04320.50
5.6.200.0100.06318.22
5.6.190.0100.07720.63
5.6.180.0330.05020.39
5.6.170.0200.05020.40
5.6.160.0130.07720.43
5.6.150.0130.07718.25
5.6.140.0070.04018.21
5.6.130.0000.04318.15
5.6.120.0130.06721.04
5.6.110.0070.08021.12
5.6.100.0130.07321.11
5.6.90.0070.08020.98
5.6.80.0100.03320.29
5.5.350.0300.04020.39
5.5.340.0100.07317.97
5.5.330.0100.06020.47
5.5.320.0530.05720.20
5.5.310.0230.05020.30
5.5.300.0130.08317.95
5.5.290.0030.08317.95
5.5.280.0130.07720.84
5.5.270.0100.08720.87
5.5.260.0100.08320.87
5.5.250.0070.06020.79
5.5.240.0130.03720.28

preferences:
50.37 ms | 400 KiB | 5 Q