3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fruitpacks = [ ['apples', 3], ['pears', 1], ['apples', 6], ['grapes', 22], ]; final class Basket { private $items; private function __construct(array $items) { $this->items = $items; } public function add(string $name, int $quantity) : self { return new self([$name => $quantity + ($this->items[$name] ?? 0)] + $this->items); } public function asArray() : array { return $this->items; } public static function empty() : self { return new self([]); } public static function addToBasket(self $basket, array $item) : self { return $basket->add(...$item); } } var_dump(array_reduce($fruitpacks, [Basket::class, 'addToBasket'], Basket::empty())->asArray());

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.4.120.0100.00920.50
8.4.110.0140.00622.45
8.4.100.0040.00518.00
8.4.90.0140.00918.54
8.4.80.0060.00317.90
8.4.70.0140.01117.93
8.4.60.0070.00518.73
8.4.50.0110.01018.91
8.4.40.0080.00417.71
8.4.30.0130.00717.78
8.4.20.0140.00719.58
8.4.10.0030.00719.46
8.3.250.0130.00618.96
8.3.240.0090.01116.73
8.3.230.0120.00616.80
8.3.220.0090.00817.15
8.3.210.0050.00316.70
8.3.200.0030.00516.71
8.3.190.0130.00617.44
8.3.180.0120.00717.34
8.3.170.0120.00320.57
8.3.160.0040.01518.58
8.3.150.0150.00417.06
8.3.140.0100.00016.51
8.3.130.0060.00316.57
8.3.120.0030.00718.96
8.3.110.0000.01020.94
8.3.100.0030.00618.41
8.3.90.0040.00426.77
8.3.80.0040.00417.97
8.3.70.0120.00916.75
8.3.60.0040.01118.30
8.3.50.0080.00517.28
8.3.40.0070.01119.04
8.3.30.0090.00618.68
8.3.20.0000.00820.33
8.3.10.0080.00023.66
8.3.00.0040.00419.51
8.2.290.0070.00320.83
8.2.280.0110.00718.72
8.2.270.0070.01117.27
8.2.260.0110.00418.28
8.2.250.0040.00418.36
8.2.240.0090.00017.47
8.2.230.0000.01522.58
8.2.220.0060.00324.06
8.2.210.0050.00226.77
8.2.200.0030.00616.63
8.2.190.0060.00916.58
8.2.180.0110.00416.38
8.2.170.0100.00722.96
8.2.160.0100.00722.25
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0030.00622.30
8.2.120.0040.00426.35
8.2.110.0000.00920.39
8.2.100.0000.01117.78
8.2.90.0000.00817.84
8.2.80.0000.00817.97
8.2.70.0090.00017.93
8.2.60.0030.00618.22
8.2.50.0000.00818.10
8.2.40.0060.00320.61
8.2.30.0000.00719.27
8.2.20.0040.00418.07
8.2.10.0040.00418.08
8.2.00.0000.00718.18
8.1.330.0100.00922.09
8.1.320.0130.00616.14
8.1.310.0030.01616.66
8.1.300.0050.00518.29
8.1.290.0060.00330.84
8.1.280.0040.01125.92
8.1.270.0050.00320.08
8.1.260.0000.00826.35
8.1.250.0090.00028.09
8.1.240.0040.00422.55
8.1.230.0080.00322.66
8.1.220.0050.00317.74
8.1.210.0000.00918.77
8.1.200.0050.00517.48
8.1.190.0030.00617.36
8.1.180.0040.00418.10
8.1.170.0060.00318.65
8.1.160.0040.00418.86
8.1.150.0040.00420.52
8.1.140.0070.00017.66
8.1.130.0030.00518.99
8.1.120.0030.00517.32
8.1.110.0040.00417.43
8.1.100.0000.00917.42
8.1.90.0050.00217.34
8.1.80.0030.00517.43
8.1.70.0040.00417.45
8.1.60.0030.00617.63
8.1.50.0030.00717.45
8.1.40.0040.00417.42
8.1.30.0000.00817.57
8.1.20.0000.00817.57
8.1.10.0000.00717.58
8.1.00.0090.00017.44
8.0.300.0050.00219.86
8.0.290.0090.00016.75
8.0.280.0030.00318.47
8.0.270.0000.00717.28
8.0.260.0030.00319.00
8.0.250.0030.00317.02
8.0.240.0050.00316.93
8.0.230.0000.00716.94
8.0.220.0000.00716.79
8.0.210.0020.00516.88
8.0.200.0040.00416.99
8.0.190.0040.00416.85
8.0.180.0020.00516.91
8.0.170.0030.00616.95
8.0.160.0030.00616.88
8.0.150.0000.00716.84
8.0.140.0030.00716.74
8.0.130.0000.00513.40
8.0.120.0040.00416.79
8.0.110.0040.00416.82
8.0.100.0040.00416.90
8.0.90.0000.00716.73
8.0.80.0030.01416.98
8.0.70.0000.00816.79
8.0.60.0040.00416.80
8.0.50.0000.00816.88
8.0.30.0150.00517.16
8.0.20.0100.01117.41
8.0.10.0050.00216.84
8.0.00.0160.00216.77
7.4.330.0000.00615.55
7.4.320.0040.00416.64
7.4.300.0070.00016.53
7.4.290.0000.00716.38
7.4.280.0000.00816.63
7.4.270.0030.00316.55
7.4.260.0030.00416.51
7.4.250.0000.00716.50
7.4.240.0040.00416.42
7.4.230.0030.00316.65
7.4.220.0060.00316.65
7.4.210.0100.00816.59
7.4.200.0000.00716.44
7.4.160.0120.00616.56
7.4.150.0040.01417.40
7.4.140.0100.01117.86
7.4.130.0090.00916.68
7.4.120.0100.00916.45
7.4.110.0040.01616.64
7.4.100.0000.01716.52
7.4.90.0040.01316.50
7.4.80.0130.01019.39
7.4.70.0080.00816.47
7.4.60.0100.01016.50
7.4.50.0130.00316.52
7.4.40.0120.00616.65
7.4.00.0070.01015.03
7.3.330.0000.00613.36
7.3.320.0000.00813.39
7.3.310.0040.00416.38
7.3.300.0040.00416.37
7.3.290.0050.00216.38
7.3.280.0080.01216.27
7.3.270.0080.00917.40
7.3.260.0060.01216.55
7.3.250.0120.00516.59
7.3.240.0070.01216.41
7.3.230.0040.01216.42
7.3.210.0100.00716.59
7.3.200.0150.00816.41
7.3.190.0120.00416.69
7.3.180.0080.00816.42
7.3.170.0040.01116.46
7.3.160.0070.01016.51
7.3.120.0040.01514.86
7.3.110.0090.00615.04
7.3.100.0040.01214.67
7.3.90.0000.01714.93
7.3.80.0090.00315.19
7.3.70.0030.01114.83
7.3.60.0060.00314.56
7.3.50.0070.00714.83
7.3.40.0030.01414.94
7.3.30.0080.00814.88
7.3.20.0100.00716.76
7.3.10.0030.01416.73
7.3.00.0030.01016.66
7.2.330.0030.01316.61
7.2.320.0190.00316.71
7.2.310.0000.01616.41
7.2.300.0090.00616.51
7.2.290.0060.01016.72
7.2.240.0030.01514.63
7.2.230.0120.00315.00
7.2.220.0040.01115.27
7.2.210.0030.01015.03
7.2.200.0000.01215.24
7.2.190.0130.00315.07
7.2.180.0030.01015.04
7.2.170.0060.00615.15
7.2.160.0000.01015.23
7.2.150.0120.00016.99
7.2.140.0090.00617.06
7.2.130.0100.00716.60
7.2.120.0090.00916.88
7.2.110.0100.00317.01
7.2.100.0040.01117.15
7.2.90.0000.01416.98
7.2.80.0000.01517.20
7.2.70.0030.00716.95
7.2.60.0050.00917.08
7.2.50.0040.00816.83
7.2.40.0060.00317.11
7.2.30.0000.01116.77
7.2.20.0070.01016.87
7.2.10.0140.00617.44
7.2.00.0090.00917.44
7.1.330.0000.01315.93
7.1.320.0070.01015.97
7.1.310.0030.01015.66
7.1.300.0000.01615.74
7.1.290.0030.01316.04
7.1.280.0070.01015.75
7.1.270.0060.00915.52
7.1.260.0000.01215.79
7.1.250.0040.00815.90
7.1.200.0100.00315.54
7.1.130.0170.00616.97
7.1.120.0260.00917.05
7.1.110.0090.01216.07
7.1.100.0100.01016.20
7.1.90.0130.00716.33
7.1.80.0140.00616.31
7.1.70.0910.01015.43
7.1.60.0280.00733.21
7.1.50.0220.01233.19
7.1.40.0230.01332.71
7.1.30.0190.01632.53
7.1.20.0270.00732.75
7.1.10.0140.00714.78
7.1.00.0140.00714.77

preferences:
27.99 ms | 403 KiB | 5 Q