3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DataStructure { private $data = []; public function __construct($data) { foreach (explode('|', $data) as $item_quantity) { list($quantity, $item) = explode(':', $item_quantity); $this->data[$item] = (int)$quantity; } } public function getItemQuantity($item) { return isset($this->data[$item]) ? $this->data[$item] : null; } public function setItemQuantity($item, $quantity) { $this->data[$item] = (int)$quantity; } public function __toString() { return implode('|', array_map(function ($item) { return $this->data[$item] . ':' . $item; }, array_keys($this->data))); } } $data = new DataStructure('3:1|8:2|5:3|4:4'); $data->setItemQuantity(4, '12'); var_dump($data->getItemQuantity(4)); var_dump($data->getItemQuantity(2)); var_dump($data->getItemQuantity(12));

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.0060.01020.75
8.4.110.0120.00822.44
8.4.100.0060.00517.56
8.4.90.0110.00918.70
8.4.80.0040.00517.92
8.4.70.0140.00717.91
8.4.60.0080.01218.91
8.4.50.0130.00622.14
8.4.40.0100.01019.64
8.4.30.0120.00822.14
8.4.20.0140.00718.66
8.4.10.0130.00619.57
8.3.250.0110.00718.81
8.3.240.0090.00916.57
8.3.230.0050.01316.51
8.3.220.0100.00917.28
8.3.210.0050.00418.46
8.3.200.0040.00516.65
8.3.190.0090.01017.01
8.3.180.0060.00316.64
8.3.170.0100.00718.86
8.3.160.0070.01116.60
8.3.150.0100.00720.77
8.3.140.0030.00619.08
8.3.130.0030.00616.58
8.3.120.0040.00719.10
8.3.110.0130.00616.76
8.3.100.0080.01224.06
8.3.90.0040.00426.77
8.3.80.0030.00618.43
8.3.70.0150.00616.25
8.3.60.0190.00016.63
8.3.50.0060.00818.15
8.3.40.0040.01118.67
8.3.30.0000.01518.70
8.3.20.0030.00620.90
8.3.10.0060.00320.66
8.3.00.0040.00420.95
8.2.290.0130.00520.26
8.2.280.0110.00918.20
8.2.270.0060.01317.17
8.2.260.0040.00416.74
8.2.250.0040.00416.67
8.2.240.0000.00817.07
8.2.230.0100.00020.94
8.2.220.0050.00337.54
8.2.210.0030.00626.77
8.2.200.0070.00416.63
8.2.190.0180.00716.58
8.2.180.0040.01118.16
8.2.170.0040.01122.96
8.2.160.0090.00922.14
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0080.00018.21
8.2.120.0080.00026.35
8.2.110.0060.00320.25
8.2.100.0030.00917.84
8.2.90.0000.01017.88
8.2.80.0040.00417.97
8.2.70.0080.00018.03
8.2.60.0030.00618.00
8.2.50.0060.00318.10
8.2.40.0060.00319.19
8.2.30.0050.00219.31
8.2.20.0000.01018.24
8.2.10.0000.00819.50
8.2.00.0040.00418.08
8.1.330.0120.00621.98
8.1.320.0080.00616.13
8.1.310.0070.00016.80
8.1.300.0150.00320.43
8.1.290.0060.00330.84
8.1.280.0160.00025.92
8.1.270.0050.00322.04
8.1.260.0020.00526.35
8.1.250.0040.00428.09
8.1.240.0090.00022.05
8.1.230.0030.00719.08
8.1.220.0040.00417.78
8.1.210.0000.00820.89
8.1.200.0060.00317.48
8.1.190.0060.00317.35
8.1.180.0000.00818.10
8.1.170.0080.00018.62
8.1.160.0040.00418.89
8.1.150.0040.00418.80
8.1.140.0070.00020.27
8.1.130.0000.00717.38
8.1.120.0000.00817.48
8.1.110.0070.00017.48
8.1.100.0040.00417.38
8.1.90.0070.00017.41
8.1.80.0000.00717.43
8.1.70.0060.00317.44
8.1.60.0050.00317.60
8.1.50.0000.00817.56
8.1.40.0040.00417.53
8.1.30.0080.00017.72
8.1.20.0030.00517.64
8.1.10.0050.00217.57
8.1.00.0040.00417.43
8.0.300.0000.00720.09
8.0.290.0050.00216.63
8.0.280.0070.00018.53
8.0.270.0040.00416.84
8.0.260.0060.00016.77
8.0.250.0030.00617.01
8.0.240.0080.00016.94
8.0.230.0000.00817.03
8.0.220.0040.00416.92
8.0.210.0070.00016.79
8.0.200.0000.00716.95
8.0.190.0000.00816.93
8.0.180.0000.00716.95
8.0.170.0000.00816.89
8.0.160.0000.00716.95
8.0.150.0040.00416.84
8.0.140.0030.00716.89
8.0.130.0040.00413.38
8.0.120.0040.00416.88
8.0.110.0000.00716.91
8.0.100.0000.00716.89
8.0.90.0040.00416.91
8.0.80.0030.01316.79
8.0.70.0000.00716.79
8.0.60.0040.00416.86
8.0.50.0070.00016.86
8.0.30.0140.00617.04
8.0.20.0140.01017.40
8.0.10.0030.00516.84
8.0.00.0100.00916.66
7.4.330.0030.00315.55
7.4.320.0030.00316.50
7.4.300.0000.00616.59
7.4.290.0030.00316.55
7.4.280.0000.00716.51
7.4.270.0030.00316.55
7.4.260.0000.01116.60
7.4.250.0000.00716.46
7.4.240.0000.00716.66
7.4.230.0000.00716.50
7.4.220.0080.00016.51
7.4.210.0070.00916.51
7.4.200.0050.00316.69
7.4.160.0090.00716.47
7.4.140.0040.01617.86
7.4.130.0080.01116.52
7.4.120.0090.00916.42
7.4.110.0060.01216.56
7.4.100.0090.01216.59
7.4.90.0000.01716.68
7.4.80.0070.01319.39
7.4.70.0130.00316.56
7.4.60.0160.00816.59
7.4.50.0090.00916.33
7.4.40.0090.01216.30
7.4.00.0030.01414.75
7.3.330.0030.00313.20
7.3.320.0000.00613.45
7.3.310.0040.00416.40
7.3.300.0030.00316.37
7.3.290.0070.00716.38
7.3.280.0090.00716.33
7.3.260.0120.00816.50
7.3.240.0100.00816.48
7.3.230.0140.00316.53
7.3.210.0110.00716.26
7.3.200.0060.01016.32
7.3.190.0090.00916.56
7.3.180.0100.00616.55
7.3.170.0210.00416.41
7.3.160.0130.00316.60
7.3.20.0830.00314.63
7.3.10.0950.00914.94
7.3.00.0780.00714.68
7.2.330.0060.01216.62
7.2.320.0110.00616.80
7.2.310.0100.00716.77
7.2.300.0040.01216.46
7.2.290.0210.00316.65
7.2.150.1270.00715.08
7.2.140.1040.00714.82
7.2.130.0890.00715.28
7.2.120.1050.00314.96
7.2.110.0960.01014.81
7.2.100.0900.00915.05
7.2.90.1130.00015.05
7.2.80.1030.00715.17
7.2.70.2340.00015.06
7.2.60.1230.00415.13
7.2.50.0930.00315.11
7.2.40.0990.00415.17
7.2.30.1120.00314.96
7.2.20.1100.00614.98
7.2.10.0990.00715.01
7.2.00.0930.00615.06
7.1.250.0820.01014.04

preferences:
127.04 ms | 403 KiB | 5 Q