3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); namespace Acme { 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 property(string $property): callable { return function ($key, $value) use ($property) { return $value->$property; }; } } } namespace { use Acme\Collection; echo (new Collection([ 'one', 'two', (object)['foo' => 'FOO', 'bar' => 'BAR', 'baz' => 'BAZ'], 'three', (object)['bar' => 'BAR', 'qux' => 'QUX'], ])) ->filter('is_object') ->map(Collection::property('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.0040.01118.68
8.3.50.0100.00921.28
8.3.40.0120.00318.87
8.3.30.0110.00418.97
8.3.20.0040.00420.16
8.3.10.0050.00323.61
8.3.00.0050.00223.68
8.2.180.0150.00018.41
8.2.170.0120.00322.96
8.2.160.0070.00720.27
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0030.00619.83
8.2.120.0070.00026.35
8.2.110.0030.00622.11
8.2.100.0040.00817.93
8.2.90.0080.00019.26
8.2.80.0030.00517.97
8.2.70.0090.00017.75
8.2.60.0080.00017.93
8.2.50.0030.00518.07
8.2.40.0000.00822.10
8.2.30.0040.00419.43
8.2.20.0040.00417.71
8.2.10.0080.00018.12
8.2.00.0030.00518.03
8.1.280.0070.00725.92
8.1.270.0040.00423.79
8.1.260.0040.00428.09
8.1.250.0140.00028.09
8.1.240.0080.00023.81
8.1.230.0080.00418.95
8.1.220.0000.00817.75
8.1.210.0050.00318.77
8.1.200.0030.00617.35
8.1.190.0040.00417.22
8.1.180.0030.00518.10
8.1.170.0060.00318.48
8.1.160.0040.00420.70
8.1.150.0040.00418.82
8.1.140.0000.00819.48
8.1.130.0030.00317.66
8.1.120.0040.00417.46
8.1.110.0050.00317.37
8.1.100.0090.00017.46
8.1.90.0030.00417.50
8.1.80.0040.00417.39
8.1.70.0040.00417.45
8.1.60.0040.00417.56
8.1.50.0030.00617.39
8.1.40.0040.00417.50
8.1.30.0040.00417.68
8.1.20.0000.00817.59
8.1.10.0000.00817.54
8.1.00.0030.00617.50
8.0.300.0040.00418.77
8.0.290.0000.00716.75
8.0.280.0070.00018.41
8.0.270.0000.00717.19
8.0.260.0030.00317.21
8.0.250.0050.00317.07
8.0.240.0000.00717.11
8.0.230.0000.00717.02
8.0.220.0000.00716.97
8.0.210.0040.00416.99
8.0.200.0030.00316.90
8.0.190.0050.00217.10
8.0.180.0000.00717.05
8.0.170.0000.00816.92
8.0.160.0050.00316.88
8.0.150.0000.00716.93
8.0.140.0000.00716.97
8.0.130.0030.00313.39
8.0.120.0000.00916.82
8.0.110.0050.00316.89
8.0.100.0070.00016.93
8.0.90.0000.00716.85
8.0.80.0090.00616.91
8.0.70.0040.00416.81
8.0.60.0040.00417.05
8.0.50.0000.00816.92
8.0.30.0080.01117.31
8.0.20.0100.01417.40
8.0.10.0050.00316.90
8.0.00.0150.00616.83
7.4.330.0000.00616.80
7.4.320.0000.00716.55
7.4.300.0000.00816.63
7.4.290.0060.00316.53
7.4.280.0090.00716.52
7.4.270.0070.00016.54
7.4.260.0030.00316.44
7.4.250.0050.00316.50
7.4.240.0040.00416.65
7.4.230.0000.00716.61
7.4.220.0160.00316.74
7.4.210.0080.00616.50
7.4.200.0000.00716.63
7.4.160.0130.00316.56
7.4.150.0120.00617.40
7.4.140.0090.01017.86
7.4.130.0110.00816.63
7.4.120.0090.00916.41
7.4.110.0130.00316.64
7.4.100.0070.01116.55
7.4.90.0070.01416.58
7.4.80.0060.01119.39
7.4.70.0100.00716.69
7.4.60.0030.01416.65
7.4.50.0060.00616.50
7.4.40.0100.01316.45
7.4.30.0180.00016.46
7.4.00.0040.01415.21
7.3.330.0000.00513.45
7.3.320.0000.00613.24
7.3.310.0070.00016.51
7.3.300.0000.00716.45
7.3.290.0040.00416.37
7.3.280.0090.01016.46
7.3.270.0120.00917.40
7.3.260.0140.00316.38
7.3.250.0080.00916.54
7.3.240.0060.01216.51
7.3.230.0060.01616.49
7.3.210.0110.00616.37
7.3.200.0070.01419.39
7.3.190.0070.01016.68
7.3.180.0030.01316.59
7.3.170.0120.00916.57
7.3.160.0070.01016.71
7.2.330.0090.00916.45
7.2.320.0030.02116.88
7.2.310.0100.00716.81
7.2.300.0100.01016.82
7.2.290.0120.01216.82
7.2.60.0070.01016.93
7.2.00.0040.00419.38
7.1.200.0100.00615.74
7.1.100.0030.01017.94
7.1.70.0030.00617.18
7.1.60.0030.02219.30
7.1.50.0000.01117.01
7.1.00.0070.07022.36
7.0.200.0030.00516.59
7.0.60.0200.07721.87
7.0.50.0030.05017.90
7.0.40.0000.04720.21
7.0.30.0200.07320.07
7.0.20.0230.06720.15
7.0.10.0030.08720.33
7.0.00.0000.05020.07
5.6.280.0000.03320.82
5.6.210.0100.03320.47
5.6.200.0070.08018.18
5.6.190.0030.07320.57
5.6.180.0570.06320.60
5.6.170.0270.06720.44
5.6.160.0170.06720.50
5.6.150.0070.08318.29
5.6.140.0030.08718.15
5.6.130.0070.08318.21
5.6.120.0130.05721.15
5.6.110.0170.07720.99
5.6.100.0070.05020.98
5.6.90.0130.08021.00
5.6.80.0170.07020.52
5.5.350.0330.07020.41
5.5.340.0030.06317.95
5.5.330.0200.05720.42
5.5.320.0570.05020.51
5.5.310.0230.04020.27
5.5.300.0030.05317.95
5.5.290.0070.06017.98
5.5.280.0100.06720.68
5.5.270.0130.07720.85
5.5.260.0070.07720.73
5.5.250.0030.06020.70
5.5.240.0030.03720.13

preferences:
31.32 ms | 401 KiB | 5 Q