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 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() ->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.01116.63
8.3.50.0140.00521.27
8.3.40.0150.00318.79
8.3.30.0150.00018.61
8.3.20.0050.00220.21
8.3.10.0050.00323.65
8.3.00.0040.00423.45
8.2.180.0070.01425.92
8.2.170.0120.00319.20
8.2.160.0070.01122.96
8.2.150.0000.00725.66
8.2.140.0000.00724.66
8.2.130.0000.00819.95
8.2.120.0040.00426.35
8.2.110.0060.00322.25
8.2.100.0040.00818.05
8.2.90.0080.00019.34
8.2.80.0040.00418.00
8.2.70.0040.00417.75
8.2.60.0060.00318.05
8.2.50.0050.00318.07
8.2.40.0000.00822.19
8.2.30.0000.00719.45
8.2.20.0040.00417.94
8.2.10.0040.00418.13
8.2.00.0000.00818.11
8.1.280.0180.00625.92
8.1.270.0040.00424.66
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0030.00623.93
8.1.230.0080.00419.14
8.1.220.0060.00318.04
8.1.210.0030.00618.77
8.1.200.0040.00417.38
8.1.190.0050.00317.48
8.1.180.0040.00418.10
8.1.170.0040.00418.65
8.1.160.0020.00520.74
8.1.150.0040.00419.02
8.1.140.0040.00419.64
8.1.130.0030.00317.81
8.1.120.0000.00717.56
8.1.110.0000.00817.38
8.1.100.0030.00517.48
8.1.90.0050.00317.45
8.1.80.0000.00817.53
8.1.70.0000.00717.54
8.1.60.0040.00417.54
8.1.50.0030.00617.54
8.1.40.0000.00817.59
8.1.30.0060.00317.73
8.1.20.0040.00417.52
8.1.10.0000.00817.61
8.1.00.0080.00017.44
8.0.300.0080.00018.77
8.0.290.0040.00416.88
8.0.280.0030.00318.55
8.0.270.0030.00317.31
8.0.260.0030.00317.31
8.0.250.0040.00417.13
8.0.240.0040.00416.98
8.0.230.0030.00317.10
8.0.220.0000.00817.00
8.0.210.0040.00416.89
8.0.200.0000.00716.97
8.0.190.0000.00717.12
8.0.180.0020.00516.93
8.0.170.0050.00317.09
8.0.160.0000.00717.09
8.0.150.0040.00416.88
8.0.140.0040.00417.01
8.0.130.0000.00613.40
8.0.120.0040.00416.98
8.0.110.0040.00416.96
8.0.100.0040.00416.89
8.0.90.0030.00317.04
8.0.80.0090.00617.04
8.0.70.0040.00417.01
8.0.60.0040.00416.85
8.0.50.0000.00817.07
8.0.30.0100.00717.16
8.0.20.0080.01117.42
8.0.10.0070.00017.18
8.0.00.0090.01216.88
7.4.330.0050.00016.83
7.4.320.0020.00516.60
7.4.300.0040.00416.58
7.4.290.0050.00316.72
7.4.280.0100.00016.47
7.4.270.0000.00716.48
7.4.260.0060.00316.66
7.4.250.0080.00016.53
7.4.240.0040.00316.54
7.4.230.0030.00316.56
7.4.220.0130.01316.59
7.4.210.0040.01216.66
7.4.200.0070.00016.70
7.4.160.0040.01416.65
7.4.150.0130.01017.40
7.4.140.0100.01117.86
7.4.130.0150.00416.47
7.4.120.0160.00216.52
7.4.110.0030.01416.36
7.4.100.0090.01116.46
7.4.90.0100.00716.58
7.4.80.0180.00419.39
7.4.70.0030.01716.65
7.4.60.0100.01116.54
7.4.50.0080.00716.38
7.4.40.0140.00416.55
7.4.30.0120.00916.52
7.4.10.0130.00614.77
7.4.00.0030.01315.03
7.3.330.0050.00013.30
7.3.320.0060.00013.43
7.3.310.0000.00716.32
7.3.300.0030.00316.42
7.3.290.0070.00016.34
7.3.280.0050.01116.52
7.3.270.0120.00617.40
7.3.260.0100.00716.39
7.3.240.0090.00916.66
7.3.230.0090.00916.48
7.3.210.0090.00916.68
7.3.200.0100.00719.39
7.3.190.0060.01116.52
7.3.180.0060.01016.67
7.3.170.0060.01516.64
7.3.160.0060.01016.71
7.3.130.0060.01015.03
7.3.120.0070.01014.91
7.3.110.0070.01114.73
7.3.100.0070.00714.98
7.3.90.0060.00914.69
7.3.80.0110.00314.96
7.3.70.0070.00714.82
7.3.60.0090.00314.78
7.3.50.0060.00614.99
7.3.40.0060.01014.91
7.3.30.0090.00614.96
7.3.20.0030.01316.89
7.3.10.0120.01016.72
7.3.00.0140.00516.45
7.2.330.0070.01016.67
7.2.320.0080.01216.82
7.2.310.0130.00516.48
7.2.300.0050.01416.84
7.2.290.0130.01016.84
7.2.260.0030.01415.02
7.2.250.0030.01615.00
7.2.240.0120.00315.02
7.2.230.0030.01015.13
7.2.220.0110.00415.06
7.2.210.0060.01015.27
7.2.200.0030.01315.30
7.2.190.0090.00315.21
7.2.180.0070.00715.03
7.2.170.0100.00715.06
7.2.160.0060.00315.14
7.2.150.0080.00916.87
7.2.140.0000.01716.97
7.2.130.0110.00916.98
7.2.120.0090.00816.79
7.2.110.0150.00516.75
7.2.100.0060.00816.65
7.2.90.0060.01116.79
7.2.80.0090.00616.78
7.2.70.0090.00716.88
7.2.60.0090.01216.67
7.2.50.0080.00816.68
7.2.40.0110.00716.68
7.2.30.0100.01016.61
7.2.20.0090.00816.54
7.2.10.0100.00716.53
7.2.00.0100.00816.86
7.1.330.0090.00615.97
7.1.320.0090.00615.98
7.1.310.0040.00815.67
7.1.300.0060.00915.86
7.1.290.0090.00015.86
7.1.280.0030.00915.75
7.1.270.0000.01515.82
7.1.260.0040.01115.82
7.1.250.0090.00915.68
7.1.240.0030.01015.87
7.1.230.0000.01715.96
7.1.220.0080.00815.80
7.1.210.0030.00715.63
7.1.200.0090.00515.81
7.1.190.0100.00315.91
7.1.180.0030.01315.74
7.1.170.0040.00415.85
7.1.160.0120.00315.98
7.1.150.0040.00816.02
7.1.140.0000.01215.70
7.1.130.0100.00615.80
7.1.120.0040.00715.87
7.1.110.0030.00715.88
7.1.100.0030.01017.04
7.1.90.0070.00715.93
7.1.80.0030.01315.97
7.1.70.0060.00516.56
7.1.60.0080.01017.59
7.1.50.0040.01316.48
7.1.40.0040.00715.85
7.1.30.0120.00015.88
7.1.20.0070.00715.90
7.1.10.0030.01015.77
7.1.00.0000.04619.15
7.0.330.0030.00915.60
7.0.320.0030.00915.47
7.0.310.0030.00615.30
7.0.300.0030.00715.33
7.0.290.0060.00615.47
7.0.280.0060.00615.25
7.0.270.0000.01415.46
7.0.260.0140.00015.48
7.0.250.0060.00615.66
7.0.240.0060.00615.29
7.0.230.0030.01015.37
7.0.220.0000.01415.44
7.0.210.0080.00815.51
7.0.200.0020.00816.17
7.0.190.0000.01315.44
7.0.180.0030.01015.61
7.0.170.0090.00615.27
7.0.160.0100.00315.57
7.0.150.0060.00615.41
7.0.140.0060.00615.20
7.0.130.0150.00015.46
7.0.120.0070.00715.38
7.0.110.0000.00815.49
7.0.100.0040.00815.55
7.0.90.0000.00915.46
7.0.80.0070.00715.27
7.0.70.0070.00715.32
7.0.60.0100.04418.62
7.0.50.0030.02416.63
7.0.40.0070.02316.93
7.0.30.0170.02816.82
7.0.20.0120.02816.96
7.0.10.0100.03716.63
7.0.00.0080.04216.69
5.6.400.0090.00314.39
5.6.390.0060.00814.18
5.6.380.0060.00914.31
5.6.370.0060.00614.35
5.6.360.0100.00314.09
5.6.350.0060.00614.14
5.6.340.0030.00714.47
5.6.330.0000.01413.95
5.6.320.0060.00314.20
5.6.310.0070.01014.25
5.6.300.0030.01014.13
5.6.290.0070.00414.30
5.6.280.0060.01817.63
5.6.270.0040.00414.20
5.6.260.0090.00614.36
5.6.250.0040.01114.01
5.6.240.0040.00814.02
5.6.230.0060.00614.20
5.6.220.0120.00314.23
5.6.210.0020.02717.42
5.6.200.0100.04316.31
5.6.190.0090.04517.36
5.6.180.0260.04017.32
5.6.170.0130.03017.31
5.6.160.0080.03717.35
5.6.150.0070.04516.28
5.6.140.0040.04316.14
5.6.130.0110.03316.19
5.6.120.0080.04717.59
5.6.110.0070.04317.72
5.6.100.0120.04017.66
5.6.90.0070.04517.46
5.6.80.0100.04017.08
5.6.70.0030.01014.16
5.6.60.0070.00714.01
5.6.50.0040.00713.79
5.6.40.0000.01314.02
5.6.30.0060.00914.06
5.6.20.0100.00714.07
5.6.10.0000.01114.03
5.6.00.0000.01313.81
5.5.380.0040.00813.59
5.5.370.0070.00714.06
5.5.360.0030.00913.78
5.5.350.0150.04517.16
5.5.340.0070.04515.99
5.5.330.0140.03717.36
5.5.320.0280.02317.06
5.5.310.0180.04517.12
5.5.300.0080.04215.94
5.5.290.0070.04515.93
5.5.280.0120.04217.54
5.5.270.0050.02717.29
5.5.260.0080.04717.28
5.5.250.0020.04817.24
5.5.240.0100.02017.17
5.5.230.0090.00614.14
5.5.220.0110.00314.34
5.5.210.0000.01214.05
5.5.200.0060.00314.00
5.5.190.0070.01014.19
5.5.180.0060.00913.91
5.5.170.0030.00913.97
5.5.160.0110.00313.82
5.5.150.0060.00313.89
5.5.140.0030.00914.03
5.5.130.0000.01414.03
5.5.120.0070.00714.08
5.5.110.0040.00814.09
5.5.100.0060.00613.88
5.5.90.0080.00813.80
5.5.80.0110.00413.77
5.5.70.0060.00914.08
5.5.60.0090.00214.16
5.5.50.0030.00614.00
5.5.40.0130.00013.82
5.5.30.0030.01214.09
5.5.20.0000.00914.04
5.5.10.0060.00913.70
5.5.00.0100.00314.01

preferences:
41.27 ms | 401 KiB | 5 Q