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.0110.00416.50
8.3.50.0120.00316.46
8.3.40.0110.00418.93
8.3.30.0060.00918.96
8.3.20.0040.00420.16
8.3.10.0080.00023.41
8.3.00.0030.00523.66
8.2.180.0120.00616.38
8.2.170.0070.00722.96
8.2.160.0100.00319.41
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0050.00319.83
8.2.120.0000.00826.35
8.2.110.0030.00721.13
8.2.100.0070.00718.16
8.2.90.0000.00919.13
8.2.80.0040.00418.05
8.2.70.0070.00317.63
8.2.60.0040.00418.16
8.2.50.0040.00418.07
8.2.40.0040.00422.05
8.2.30.0030.00519.48
8.2.20.0040.00417.69
8.2.10.0000.00818.21
8.2.00.0040.00418.20
8.1.280.0040.01125.92
8.1.270.0030.00620.29
8.1.260.0030.00928.09
8.1.250.0040.00428.09
8.1.240.0000.00924.01
8.1.230.0040.00719.02
8.1.220.0000.00817.79
8.1.210.0100.00018.77
8.1.200.0070.00317.36
8.1.190.0100.00017.35
8.1.180.0030.00518.10
8.1.170.0080.00018.62
8.1.160.0040.00420.86
8.1.150.0000.00718.93
8.1.140.0000.00819.60
8.1.130.0040.00417.66
8.1.120.0000.00817.46
8.1.110.0000.00717.54
8.1.100.0040.00417.50
8.1.90.0000.00817.33
8.1.80.0040.00417.41
8.1.70.0000.00717.39
8.1.60.0080.00017.52
8.1.50.0040.00417.53
8.1.40.0050.00517.59
8.1.30.0050.00317.70
8.1.20.0050.00217.65
8.1.10.0050.00317.64
8.1.00.0040.00417.41
8.0.300.0050.00318.77
8.0.290.0050.00216.88
8.0.280.0050.00318.46
8.0.270.0000.00717.17
8.0.260.0030.00317.33
8.0.250.0000.00716.95
8.0.240.0070.00017.02
8.0.230.0000.00716.93
8.0.220.0000.00716.97
8.0.210.0030.00316.87
8.0.200.0000.00817.04
8.0.190.0040.00717.06
8.0.180.0050.00217.02
8.0.170.0030.00517.03
8.0.160.0040.00416.90
8.0.150.0040.00416.88
8.0.140.0070.00016.96
8.0.130.0050.00013.46
8.0.120.0030.00516.93
8.0.110.0000.00716.99
8.0.100.0050.00316.90
8.0.90.0050.00216.88
8.0.80.0130.00616.95
8.0.70.0070.00017.06
8.0.60.0000.00716.81
8.0.50.0040.00416.96
8.0.30.0120.00417.19
8.0.20.0110.01317.40
8.0.10.0080.00017.14
8.0.00.0090.00916.89
7.4.330.0050.00016.89
7.4.320.0000.00616.66
7.4.300.0050.00316.45
7.4.290.0000.00716.53
7.4.280.0030.00616.43
7.4.270.0040.00416.47
7.4.260.0000.00716.43
7.4.250.0040.00416.59
7.4.240.0040.00416.56
7.4.230.0030.00316.38
7.4.220.0100.01016.57
7.4.210.0110.00616.58
7.4.200.0000.00716.64
7.4.160.0130.00316.50
7.4.150.0110.00817.40
7.4.140.0070.01417.86
7.4.130.0100.00816.54
7.4.120.0100.00716.45
7.4.110.0090.00916.63
7.4.100.0100.00716.65
7.4.90.0060.01216.39
7.4.80.0100.01019.39
7.4.70.0070.01016.53
7.4.60.0130.00316.50
7.4.50.0130.00316.28
7.4.40.0120.00616.62
7.4.30.0180.00016.35
7.4.00.0100.00614.91
7.3.330.0050.00013.27
7.3.320.0030.00313.24
7.3.310.0040.00416.40
7.3.300.0040.00416.34
7.3.290.0030.00316.40
7.3.280.0090.00916.40
7.3.270.0130.00517.40
7.3.260.0160.01016.43
7.3.250.0100.00716.31
7.3.240.0020.01616.48
7.3.230.0110.00716.44
7.3.210.0080.01116.68
7.3.200.0130.00319.39
7.3.190.0040.01416.55
7.3.180.0140.00716.55
7.3.170.0120.00616.48
7.3.160.0100.01316.40
7.3.120.0090.00914.91
7.3.110.0070.01014.87
7.3.100.0090.00315.00
7.3.90.0040.01214.66
7.3.80.0030.00914.87
7.3.70.0060.00615.04
7.3.60.0080.00814.67
7.3.50.0000.01014.66
7.3.40.0030.01414.66
7.3.30.0070.00714.86
7.3.20.0000.01416.61
7.3.10.0020.01116.67
7.3.00.0030.01116.53
7.2.330.0120.00616.84
7.2.320.0100.01316.80
7.2.310.0050.01516.81
7.2.300.0110.01416.79
7.2.290.0030.01916.79
7.2.250.0070.01315.08
7.2.240.0120.00915.19
7.2.230.0060.00615.25
7.2.220.0070.00715.40
7.2.210.0060.01215.05
7.2.200.0070.00715.33
7.2.190.0000.01814.93
7.2.180.0050.00515.23
7.2.170.0000.01215.14
7.2.130.0030.01016.77
7.2.120.0000.01417.11
7.2.110.0030.01417.06
7.2.100.0030.00616.90
7.2.90.0000.01417.01
7.2.80.0000.01517.20
7.2.70.0040.00716.86
7.2.60.0090.00716.92
7.2.50.0090.00616.97
7.2.40.0110.00017.13
7.2.30.0070.01016.63
7.2.20.0070.00717.00
7.2.10.0030.00917.02
7.2.00.0030.01018.38
7.1.330.0030.01215.80
7.1.320.0100.00615.54
7.1.310.0070.01016.03
7.1.300.0060.00915.72
7.1.290.0040.01115.76
7.1.280.0060.00615.93
7.1.270.0070.00715.78
7.1.260.0030.00715.88
7.1.250.0030.00715.54
7.1.200.0000.01415.66
7.1.100.0070.00718.12
7.1.70.0000.01117.25
7.1.60.0030.02019.30
7.1.50.0070.01416.70
7.1.00.0030.07722.33
7.0.200.0070.01116.53
7.0.60.0130.08321.70
7.0.50.0000.04717.92
7.0.40.0030.05020.05
7.0.30.0400.08020.20
7.0.20.0170.06320.23
7.0.10.0030.09320.26
7.0.00.0100.06020.10
5.6.280.0030.06021.05
5.6.210.0070.08020.51
5.6.200.0170.07718.16
5.6.190.0030.09020.34
5.6.180.0430.07320.63
5.6.170.0300.07720.58
5.6.160.0030.04720.57
5.6.150.0130.07018.25
5.6.140.0070.07318.11
5.6.130.0030.07018.24
5.6.120.0130.07321.04
5.6.110.0130.03321.01
5.6.100.0070.07321.01
5.6.90.0070.06021.02
5.6.80.0100.07020.41
5.5.350.4330.04320.34
5.5.340.0030.07318.04
5.5.330.0030.06320.44
5.5.320.0500.06720.20
5.5.310.0170.04020.27
5.5.300.0030.08717.96
5.5.290.0070.08318.08
5.5.280.0000.06320.66
5.5.270.0070.06320.73
5.5.260.0030.06720.68
5.5.250.0170.07020.67
5.5.240.0100.06320.24

preferences:
61.57 ms | 400 KiB | 5 Q