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.0110.00921.13
8.3.40.0120.00318.96
8.3.30.0120.00318.73
8.3.20.0040.00420.38
8.3.10.0080.00023.66
8.3.00.0080.00023.66
8.2.180.0090.00618.41
8.2.170.0070.00722.96
8.2.160.0100.00719.33
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0050.00319.52
8.2.120.0070.00026.35
8.2.110.0030.00621.01
8.2.100.0120.00017.82
8.2.90.0040.00418.03
8.2.80.0040.00418.16
8.2.70.0040.00418.03
8.2.60.0030.00617.93
8.2.50.0090.00318.10
8.2.40.0040.00420.50
8.2.30.0040.00419.65
8.2.20.0000.00717.73
8.2.10.0000.00718.23
8.2.00.0080.00018.21
8.1.280.0140.00725.92
8.1.270.0040.00424.01
8.1.260.0040.00428.09
8.1.250.0080.00028.09
8.1.240.0030.00623.88
8.1.230.0060.00620.97
8.1.220.0040.00417.91
8.1.210.0030.00618.77
8.1.200.0000.00817.35
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0060.00318.59
8.1.160.0040.00422.12
8.1.150.0040.00418.84
8.1.140.0040.00419.60
8.1.130.0030.00317.65
8.1.120.0040.00417.40
8.1.110.0040.00417.52
8.1.100.0040.00417.43
8.1.90.0050.00217.41
8.1.80.0040.00417.53
8.1.70.0000.00717.52
8.1.60.0060.00317.63
8.1.50.0080.00017.45
8.1.40.0050.00317.46
8.1.30.0000.00817.66
8.1.20.0040.00417.56
8.1.10.0040.00417.68
8.1.00.0050.00317.45
8.0.300.0030.00620.03
8.0.290.0040.00416.88
8.0.280.0000.00718.46
8.0.270.0040.00417.36
8.0.260.0000.00617.29
8.0.250.0030.00517.12
8.0.240.0030.00316.95
8.0.230.0040.00417.05
8.0.220.0020.00416.97
8.0.210.0050.00316.95
8.0.200.0060.00017.12
8.0.190.0000.00817.00
8.0.180.0040.00416.98
8.0.170.0040.00417.04
8.0.160.0040.00416.96
8.0.150.0030.00516.94
8.0.140.0040.00416.86
8.0.130.0060.00013.37
8.0.120.0080.00016.86
8.0.110.0050.00316.97
8.0.100.0040.00416.82
8.0.90.0050.00316.96
8.0.80.0100.00716.98
8.0.70.0040.00416.95
8.0.60.0030.00616.85
8.0.50.0050.00316.99
8.0.30.0020.01317.32
8.0.20.0080.01117.41
8.0.10.0080.00017.15
8.0.00.0120.00816.98
7.4.330.0000.00516.83
7.4.320.0070.00016.65
7.4.300.0030.00316.54
7.4.290.0070.00016.49
7.4.280.0000.01316.39
7.4.270.0000.00716.64
7.4.260.0070.00016.54
7.4.250.0000.00816.64
7.4.240.0030.00516.52
7.4.230.0030.00316.53
7.4.220.0120.00616.61
7.4.210.0110.00416.59
7.4.200.0000.00716.62
7.4.160.0120.00616.57
7.4.150.0150.00317.40
7.4.140.0090.01017.86
7.4.130.0180.00616.55
7.4.120.0090.00916.65
7.4.110.0070.01016.59
7.4.100.0190.00016.54
7.4.90.0100.02616.48
7.4.80.0150.00319.39
7.4.70.0030.01316.51
7.4.60.0100.00616.46
7.4.50.0030.00916.37
7.4.40.0100.00716.70
7.4.30.0030.01316.60
7.4.00.0040.01415.27
7.3.330.0050.00013.33
7.3.320.0000.00513.49
7.3.310.0000.00716.36
7.3.300.0040.00416.52
7.3.290.0040.00416.47
7.3.280.0090.00816.43
7.3.270.0130.00317.40
7.3.260.0110.00716.73
7.3.240.0120.00716.46
7.3.230.0150.00816.39
7.3.210.0140.00416.46
7.3.200.0140.00519.39
7.3.190.0000.01616.41
7.3.180.0090.00716.45
7.3.170.0030.01316.63
7.3.160.0100.00616.52
7.3.10.0000.01116.88
7.3.00.0070.00416.45
7.2.330.0040.01516.59
7.2.320.0140.00416.78
7.2.310.0070.01016.84
7.2.300.0130.00616.84
7.2.290.0120.00616.65
7.2.130.0060.00617.16
7.2.120.0070.00317.13
7.2.110.0000.00917.00
7.2.100.0090.00016.98
7.2.90.0030.00617.07
7.2.80.0030.00916.81
7.2.70.0080.00417.02
7.2.60.0070.00616.98
7.2.50.0030.00916.94
7.2.40.0090.00316.98
7.2.30.0120.00016.76
7.2.20.0060.00616.87
7.2.10.0090.00617.05
7.2.00.0010.01118.09
7.1.250.0070.00415.76
7.1.200.0060.00915.96
7.1.100.0110.00718.05
7.1.70.0050.00517.19
7.1.60.0090.01619.30
7.1.50.0040.00816.99
7.1.00.0000.08022.30
7.0.200.0000.00916.59
7.0.60.0200.07321.67
7.0.50.0030.04017.94
7.0.40.0070.04020.02
7.0.30.0230.05720.25
7.0.20.0070.05020.26
7.0.10.0070.08720.21
7.0.00.0100.06720.25
5.6.280.0030.04020.83
5.6.210.0030.04020.47
5.6.200.0070.06018.29
5.6.190.0030.04320.41
5.6.180.0570.06320.75
5.6.170.0330.05320.45
5.6.160.0070.07320.46
5.6.150.0030.08018.29
5.6.140.0100.07718.14
5.6.130.0070.07318.27
5.6.120.0270.06321.09
5.6.110.0100.08320.99
5.6.100.0130.07321.05
5.6.90.0100.05721.09
5.6.80.0130.07020.36
5.5.350.0230.05320.34
5.5.340.0070.03717.99
5.5.330.0100.08020.35
5.5.320.0430.05020.41
5.5.310.0200.04020.34
5.5.300.0070.04317.98
5.5.290.0030.08017.98
5.5.280.0030.04320.88
5.5.270.0170.07320.66
5.5.260.0170.05320.89
5.5.250.0070.07020.69
5.5.240.0130.05020.17

preferences:
54.08 ms | 401 KiB | 5 Q