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 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 static function not(callable $callback): callable { return function ($key, $value) use ($callback) { return !call_user_func($callback, $key, $value); }; } public function values(): array { return $this->_items; } } } namespace { use Acme\Collection; echo (new Collection([ 'one', 'two', (object)['foo' => 'FOO', 'bar' => 'BAR', 'baz' => 'BAZ'], 'three', (object)['bar' => 'BAR', 'qux' => 'QUX'], ])) ->filter(Collection::not('is_string')) ->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.70.0080.00816.71
8.3.60.0110.00418.56
8.3.50.0160.00521.27
8.3.40.0000.01618.99
8.3.30.0110.00418.84
8.3.20.0040.00420.11
8.3.10.0090.00023.39
8.3.00.0000.00823.53
8.2.180.0120.00318.66
8.2.170.0150.00622.96
8.2.160.0100.00320.38
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0080.00019.89
8.2.120.0040.00426.35
8.2.110.0060.00322.08
8.2.100.0030.01018.16
8.2.90.0000.00919.16
8.2.80.0000.00817.97
8.2.70.0000.00917.75
8.2.60.0000.00818.05
8.2.50.0040.00418.07
8.2.40.0040.00422.32
8.2.30.0070.00019.55
8.2.20.0000.00717.98
8.2.10.0050.00318.17
8.2.00.0000.00917.98
8.1.280.0030.01025.92
8.1.270.0060.00323.86
8.1.260.0080.00028.09
8.1.250.0040.00428.09
8.1.240.0000.00923.79
8.1.230.0070.00319.02
8.1.220.0090.00017.74
8.1.210.0030.00618.77
8.1.200.0050.00517.22
8.1.190.0040.00417.22
8.1.180.0060.00318.10
8.1.170.0040.00418.64
8.1.160.0040.00420.82
8.1.150.0020.00518.90
8.1.140.0080.00019.69
8.1.130.0000.00717.76
8.1.120.0040.00417.52
8.1.110.0040.00417.50
8.1.100.0000.00817.48
8.1.90.0040.00417.52
8.1.80.0000.00717.48
8.1.70.0070.00017.44
8.1.60.0000.00817.62
8.1.50.0030.00617.47
8.1.40.0060.00317.46
8.1.30.0030.00617.63
8.1.20.0000.00817.58
8.1.10.0040.00417.54
8.1.00.0000.00817.40
8.0.300.0000.00718.77
8.0.290.0060.00317.00
8.0.280.0030.00318.41
8.0.270.0000.00717.21
8.0.260.0000.00617.30
8.0.250.0030.00317.06
8.0.240.0000.00717.07
8.0.230.0040.00417.05
8.0.220.0030.00316.91
8.0.210.0000.00816.94
8.0.200.0030.00317.03
8.0.190.0030.00316.90
8.0.180.0040.00417.04
8.0.170.0080.00017.05
8.0.160.0040.00417.01
8.0.150.0000.00716.88
8.0.140.0030.00616.97
8.0.130.0000.00613.39
8.0.120.0000.00916.96
8.0.110.0070.00016.91
8.0.100.0040.00416.87
8.0.90.0050.00317.01
8.0.80.0060.01016.97
8.0.70.0000.00816.96
8.0.60.0000.00816.99
8.0.50.0040.00416.81
8.0.30.0100.00917.15
8.0.20.0150.00417.40
8.0.10.0000.00717.13
8.0.00.0130.00716.87
7.4.330.0050.00016.66
7.4.320.0000.00716.61
7.4.300.0030.00516.57
7.4.290.0030.00316.64
7.4.280.0090.00016.54
7.4.270.0030.00316.64
7.4.260.0060.00316.43
7.4.250.0040.00416.54
7.4.240.0040.00416.66
7.4.230.0070.00016.45
7.4.220.0090.01516.67
7.4.210.0100.00716.55
7.4.200.0030.00316.75
7.4.160.0060.01116.43
7.4.150.0110.00617.40
7.4.140.0100.01017.86
7.4.130.0150.00516.52
7.4.120.0090.00916.61
7.4.110.0120.00616.64
7.4.100.0030.01516.64
7.4.90.0110.01816.43
7.4.80.0170.00019.39
7.4.70.0120.00616.64
7.4.60.0100.00716.51
7.4.50.0070.00716.47
7.4.40.0100.01316.78
7.4.30.0100.00716.70
7.4.00.0000.01415.09
7.3.330.0060.00013.32
7.3.320.0030.00313.20
7.3.310.0030.00316.44
7.3.300.0030.00316.47
7.3.290.0040.00316.43
7.3.280.0100.00916.39
7.3.270.0030.01317.40
7.3.260.0090.00916.45
7.3.250.0040.01516.49
7.3.240.0130.00816.48
7.3.230.0030.01816.60
7.3.210.0030.01316.49
7.3.200.0140.00719.39
7.3.190.0160.00016.41
7.3.180.0130.00316.62
7.3.170.0060.01616.66
7.3.160.0120.00716.57
7.3.00.0120.00316.64
7.2.330.0180.00016.75
7.2.320.0110.00616.88
7.2.310.0060.01216.71
7.2.300.0060.01216.92
7.2.290.0120.01216.63
7.2.130.0130.00716.64
7.2.120.0060.00916.91
7.2.110.0070.00716.89
7.2.100.0100.00716.79
7.2.90.0140.01016.94
7.2.80.0110.00716.64
7.2.70.0120.00616.55
7.2.60.0090.01016.79
7.2.50.0110.00716.89
7.2.40.0120.00616.88
7.2.30.0120.00617.09
7.2.20.0150.00016.70
7.2.10.0060.00616.61
7.2.00.0060.01218.23
7.1.250.0100.00315.56
7.1.240.0070.00715.88
7.1.230.0070.00715.91
7.1.220.0110.00815.82
7.1.210.0150.00315.75
7.1.200.0080.00615.78
7.1.190.0090.00615.60
7.1.180.0110.00715.51
7.1.170.0110.00715.37
7.1.160.0140.00715.51
7.1.150.0170.00315.71
7.1.140.0130.00615.50
7.1.130.0100.00715.81
7.1.120.0080.00615.62
7.1.110.0030.01315.74
7.1.100.0120.00717.04
7.1.90.0130.00315.83
7.1.80.0090.00915.47
7.1.70.0070.00816.31
7.1.60.0090.01417.46
7.1.50.0070.00716.22
7.1.40.0070.00715.83
7.1.30.0090.00915.85
7.1.20.0070.01115.76
7.1.10.0100.00515.65
7.1.00.0110.04018.94
7.0.330.0050.01015.29
7.0.320.0090.00915.48
7.0.310.0110.00315.23
7.0.300.0060.01415.55
7.0.290.0210.00015.53
7.0.280.0130.00615.05
7.0.270.0040.01115.32
7.0.260.0200.00315.07
7.0.250.0080.00915.25
7.0.240.0140.00315.23
7.0.230.0150.00415.07
7.0.220.0070.00414.96
7.0.210.0080.00815.28
7.0.200.0100.00415.99
7.0.190.0070.00714.97
7.0.180.0100.00315.26
7.0.170.0110.00315.36
7.0.160.0040.01215.18
7.0.150.0090.00915.39
7.0.140.0100.01015.41
7.0.130.0130.00315.07
7.0.120.0140.00315.49
7.0.110.0120.00615.50
7.0.100.0070.01315.44
7.0.90.0070.00715.43
7.0.80.0120.00315.41
7.0.70.0070.01315.43
7.0.60.0130.03118.48
7.0.50.0030.02816.68
7.0.40.0030.02716.80
7.0.30.0140.04316.62
7.0.20.0100.03016.82
7.0.10.0030.04916.68
7.0.00.0070.04816.62
5.6.380.0030.01013.98
5.6.370.0040.01414.34
5.6.360.0100.01014.31
5.6.350.0060.01314.10
5.6.340.0000.01813.83
5.6.330.0040.01214.00
5.6.320.0060.01113.91
5.6.310.0040.01113.69
5.6.300.0080.00813.88
5.6.290.0070.01013.64
5.6.280.0070.02817.49
5.6.270.0030.00914.07
5.6.260.0100.00613.83
5.6.250.0040.01314.14
5.6.240.0030.01013.67
5.6.230.0030.01413.65
5.6.220.0130.00414.18
5.6.210.0070.02717.40
5.6.200.0100.04616.03
5.6.190.0060.02617.14
5.6.180.0280.03217.36
5.6.170.0220.03517.31
5.6.160.0080.03117.31
5.6.150.0110.04015.92
5.6.140.0080.03616.04
5.6.130.0090.04216.03
5.6.120.0140.04117.51
5.6.110.0060.04717.42
5.6.100.0080.04517.47
5.6.90.0030.04317.37
5.6.80.0060.04517.16
5.6.70.0090.00913.81
5.6.60.0100.00513.91
5.6.50.0110.00713.82
5.6.40.0120.00613.88
5.6.30.0130.00813.96
5.6.20.0140.01413.94
5.6.10.0030.01213.93
5.6.00.0090.00613.72
5.5.380.0050.00511.60
5.5.370.0070.00711.60
5.5.360.0090.00211.60
5.5.350.0130.04216.05
5.5.340.0020.02614.79
5.5.330.0080.04316.01
5.5.320.0160.03415.97
5.5.310.0150.02315.99
5.5.300.0070.03514.82
5.5.290.0080.04014.79
5.5.280.0090.04416.17
5.5.270.0100.04316.19
5.5.260.0080.03616.19
5.5.250.0070.04216.10
5.5.240.0070.03015.82
5.5.230.0000.01111.60
5.5.220.0070.00711.60
5.5.210.0060.00611.60
5.5.200.0070.01011.60
5.5.190.0150.00311.60
5.5.180.0110.00611.60
5.5.170.0110.00311.60
5.5.160.0000.01311.60
5.5.150.0050.01011.60
5.5.140.0030.01011.60
5.5.130.0080.00511.60
5.5.120.0030.01011.60
5.5.110.0030.00911.60
5.5.100.0050.00911.60
5.5.90.0100.00311.60
5.5.80.0040.00811.60
5.5.70.0040.00411.60
5.5.60.0080.00311.60
5.5.50.0040.01111.60
5.5.40.0030.01011.60
5.5.30.0050.00511.60
5.5.20.0000.01211.60
5.5.10.0060.00911.60
5.5.00.0040.01211.60

preferences:
73.29 ms | 401 KiB | 5 Q