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): self { return $this->map(function ($key, $value) use ($index) { return $value[$index]; }); } public function property(string $property): self { 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.00716.63
8.3.50.0150.00821.22
8.3.40.0110.00418.82
8.3.30.0140.00018.84
8.3.20.0000.00820.34
8.3.10.0040.00423.59
8.3.00.0000.00723.61
8.2.180.0070.01116.50
8.2.170.0090.00622.96
8.2.160.0070.00719.46
8.2.150.0090.00024.18
8.2.140.0030.00524.66
8.2.130.0040.00419.82
8.2.120.0080.00026.35
8.2.110.0050.00521.13
8.2.100.0080.00418.05
8.2.90.0060.00319.34
8.2.80.0000.00918.02
8.2.70.0030.00717.75
8.2.60.0000.00818.04
8.2.50.0040.00418.07
8.2.40.0060.00322.24
8.2.30.0000.00719.42
8.2.20.0000.00817.73
8.2.10.0000.00818.17
8.2.00.0050.00218.22
8.1.280.0100.00625.92
8.1.270.0080.00020.25
8.1.260.0080.00428.09
8.1.250.0020.00528.09
8.1.240.0060.00323.84
8.1.230.0090.00319.04
8.1.220.0000.00817.78
8.1.210.0030.00618.77
8.1.200.0090.00317.35
8.1.190.0000.00917.23
8.1.180.0030.00618.10
8.1.170.0030.00618.56
8.1.160.0050.00320.76
8.1.150.0050.00218.84
8.1.140.0030.00519.53
8.1.130.0040.00417.61
8.1.120.0040.00417.55
8.1.110.0040.00417.40
8.1.100.0040.00417.48
8.1.90.0040.00417.39
8.1.80.0000.00817.51
8.1.70.0030.00517.52
8.1.60.0040.00417.46
8.1.50.0030.00617.55
8.1.40.0030.00617.53
8.1.30.0080.00017.66
8.1.20.0040.00417.65
8.1.10.0080.00017.59
8.1.00.0080.00017.44
8.0.300.0040.00418.77
8.0.290.0070.00016.88
8.0.280.0000.00718.44
8.0.270.0030.00317.19
8.0.260.0030.00317.29
8.0.250.0030.00416.92
8.0.240.0030.00716.95
8.0.230.0000.00717.04
8.0.220.0050.00316.99
8.0.210.0000.00716.92
8.0.200.0000.00917.02
8.0.190.0030.00717.03
8.0.180.0070.00017.04
8.0.170.0040.00416.91
8.0.160.0000.00716.99
8.0.150.0020.00516.89
8.0.140.0000.00716.94
8.0.130.0000.00513.40
8.0.120.0030.00516.88
8.0.110.0020.00517.04
8.0.100.0050.00216.95
8.0.90.0000.00717.04
8.0.80.0010.01916.98
8.0.70.0060.00316.86
8.0.60.0050.00216.86
8.0.50.0040.00416.96
8.0.30.0060.01217.30
8.0.20.0120.00817.40
8.0.10.0000.00717.05
8.0.00.0070.01116.91
7.4.330.0050.00016.71
7.4.320.0030.00316.57
7.4.300.0030.00316.46
7.4.290.0040.00416.53
7.4.280.0060.00316.63
7.4.270.0030.00416.64
7.4.260.0030.00316.49
7.4.250.0000.00816.55
7.4.240.0020.00616.52
7.4.230.0070.00016.75
7.4.220.0150.01216.75
7.4.210.0080.00716.58
7.4.200.0080.00016.72
7.4.160.0040.01216.34
7.4.150.0090.00917.40
7.4.140.0120.01017.86
7.4.130.0110.01416.63
7.4.120.0110.01116.61
7.4.110.0150.00616.44
7.4.100.0080.00816.59
7.4.90.0110.00816.70
7.4.80.0120.00619.39
7.4.70.0110.00616.46
7.4.60.0100.00616.68
7.4.50.0100.00616.38
7.4.40.0100.01416.45
7.4.30.0150.00916.38
7.4.00.0070.01115.12
7.3.330.0030.00313.39
7.3.320.0000.00513.36
7.3.310.0030.00316.38
7.3.300.0000.00716.25
7.3.290.0050.00216.45
7.3.280.0030.01316.37
7.3.270.0090.00917.40
7.3.260.0040.01516.64
7.3.250.0100.00716.56
7.3.240.0060.01116.46
7.3.230.0130.00316.43
7.3.210.0090.00916.46
7.3.200.0170.00619.39
7.3.190.0120.00416.70
7.3.180.0030.01416.28
7.3.170.0150.00616.54
7.3.160.0140.00316.73
7.2.330.0110.00716.75
7.2.320.0140.00316.76
7.2.310.0110.00616.83
7.2.300.0160.00716.68
7.2.290.0030.01416.87
7.2.60.0080.00516.98
7.2.00.0060.00619.44
7.1.200.0030.00615.55
7.1.70.0040.00417.09
7.1.60.0070.00317.27
7.1.50.0100.01017.10
7.1.00.0100.07022.31
7.0.200.0040.01216.67
7.0.60.0130.08021.66
7.0.50.0030.05017.88
7.0.40.0230.07020.13
7.0.30.0430.07320.24
7.0.20.0270.06720.08
7.0.10.0030.06320.24
7.0.00.0030.08720.30
5.6.280.0030.06020.82
5.6.210.0070.04720.48
5.6.200.0100.08318.18
5.6.190.0030.09020.46
5.6.180.0400.04720.64
5.6.170.0370.07720.44
5.6.160.0030.04320.45
5.6.150.0070.04018.18
5.6.140.0070.05018.21
5.6.130.0000.06318.15
5.6.120.0130.06021.00
5.6.110.0030.04021.14
5.6.100.0200.06320.98
5.6.90.0100.08320.99
5.6.80.0030.08320.51
5.5.350.4230.04020.45
5.5.340.0100.03318.07
5.5.330.0030.07320.41
5.5.320.0370.06720.34
5.5.310.0100.04720.24
5.5.300.0030.08018.00
5.5.290.0100.06318.08
5.5.280.0170.07720.97
5.5.270.0100.08020.77
5.5.260.0030.06020.80
5.5.250.0100.07020.67
5.5.240.0100.08320.29

preferences:
52.73 ms | 401 KiB | 5 Q