3v4l.org

run code in 300+ PHP versions simultaneously
<?php //EXAMPLE, PSEUDO CODE class Cart{ protected $items = [];//array of id => [stuff] public function __construct(){ $this->read(); } //$attributes - IDK, maybe quantity or ... something... public function add(int $id, array $attributes = []){ if(isset($this->items [$id])){ //@todo - do smth about it... } $this->items [$id][] = $attributes; return $this; } public function read(){ //might change this later, to db and or serialization $this->items = json_decode((isset($_SESSION['cart']))); return $this; } public function write(){ //might change this later, to db and or serialization $_SESSION['cart'] = json_encode($this->items); return $this; } public function getItems(){ return $this->items; } } /// //thing is you don't care HERE about internal implementaion. Which can be changed later. $cart = new Cart(); $cart->add(17,['quantity' => 12]); $cart->add(42,['quantity' => 99])->write(); var_dump($cart->getItems());

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.0160.00618.27
8.3.50.0060.00918.22
8.3.40.0140.00318.84
8.3.30.0120.00318.74
8.3.20.0080.00019.10
8.3.10.0030.00521.86
8.3.00.0040.00422.43
8.2.180.0100.01018.54
8.2.170.0040.01118.95
8.2.160.0060.01220.47
8.2.150.0070.00024.18
8.2.140.0030.00524.66
8.2.130.0080.00026.16
8.2.120.0040.00421.06
8.2.110.0060.00619.34
8.2.100.0090.00317.84
8.2.90.0040.00418.03
8.2.80.0030.00619.89
8.2.70.0050.00318.18
8.2.60.0050.00318.00
8.2.50.0030.00518.28
8.2.40.0060.00321.12
8.2.30.0050.00321.30
8.2.20.0040.00418.18
8.2.10.0040.00418.12
8.2.00.0000.00719.25
8.1.280.0070.01025.92
8.1.270.0040.00422.04
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00322.60
8.1.230.0100.00021.04
8.1.220.0080.00017.74
8.1.210.0000.00818.77
8.1.200.0040.00717.25
8.1.190.0060.00617.35
8.1.180.0080.00018.10
8.1.170.0030.00618.55
8.1.160.0040.00418.94
8.1.150.0060.00318.77
8.1.140.0000.00717.64
8.1.130.0040.00417.45
8.1.120.0000.00717.54
8.1.110.0000.00717.44
8.1.100.0050.00217.36
8.1.90.0080.00017.46
8.1.80.0000.00717.46
8.1.70.0030.00317.35
8.1.60.0090.00017.48
8.1.50.0040.00417.41
8.1.40.0050.00217.42
8.1.30.0070.00317.60
8.1.20.0070.00017.59
8.1.10.0030.00617.55
8.1.00.0000.00717.50
8.0.300.0050.00319.98
8.0.290.0000.00716.63
8.0.280.0040.00418.46
8.0.270.0030.00617.27
8.0.260.0000.00716.87
8.0.250.0000.00716.94
8.0.240.0000.00816.97
8.0.230.0070.00016.94
8.0.220.0000.00716.88
8.0.210.0040.00416.83
8.0.200.0030.00316.85
8.0.190.0040.00416.95
8.0.180.0040.00416.96
8.0.170.0030.00616.80
8.0.160.0040.00416.87
8.0.150.0050.00316.86
8.0.140.0030.00316.88
8.0.130.0000.00713.36
8.0.120.0000.00716.71
8.0.110.0040.00416.96
8.0.100.0000.00816.80
8.0.90.0000.00716.88
8.0.80.0060.00916.96
8.0.70.0030.00516.70
8.0.60.0000.00716.90
8.0.50.0070.00016.75
8.0.30.0090.01117.10
8.0.20.0140.00617.40
8.0.10.0070.00017.09
8.0.00.0120.00616.84
7.4.330.0020.00215.55
7.4.320.0000.00616.46
7.4.300.0070.00016.56
7.4.290.0050.00316.50
7.4.280.0030.00516.63
7.4.270.0030.00316.62
7.4.260.0030.00716.59
7.4.250.0030.00516.58
7.4.240.0070.00016.64
7.4.230.0070.00016.71
7.4.220.0030.00516.49
7.4.210.0080.00716.54
7.4.200.0040.00416.42
7.4.160.0100.01016.56
7.4.140.0090.01017.86
7.4.130.0090.00916.48
7.4.120.0130.00916.52
7.4.110.0150.00316.55
7.4.100.0100.00816.39
7.4.90.0090.00916.65
7.4.80.0120.00619.39
7.4.70.0190.01316.41
7.4.60.0060.00916.51
7.4.50.0110.00816.58
7.4.40.0110.00716.48
7.4.00.0050.01214.99
7.3.330.0020.00213.15
7.3.320.0030.00313.36
7.3.310.0050.00316.27
7.3.300.0070.00016.35
7.3.290.0110.00716.34
7.3.280.0120.00716.39
7.3.260.0110.00716.48
7.3.240.0090.01016.49
7.3.230.0040.01416.61
7.3.210.0060.01216.66
7.3.200.0060.01016.44
7.3.190.0100.01016.50
7.3.180.0160.00016.51
7.3.170.0100.01416.39
7.3.160.0080.00816.53
7.3.120.0080.00914.92
7.3.110.0070.01014.70
7.3.100.0080.00914.76
7.3.90.0060.00714.75
7.3.80.0070.00514.77
7.3.70.0050.00814.80
7.3.60.0100.00414.83
7.3.50.0040.01014.73
7.3.40.0060.00614.80
7.3.30.0060.00714.66
7.3.20.0090.00616.68
7.3.10.0050.00816.55
7.3.00.0060.00616.56
7.2.330.0040.01516.64
7.2.320.0120.00616.74
7.2.310.0150.00416.66
7.2.300.0130.01016.71
7.2.290.0100.01016.77
7.2.250.0060.01015.12
7.2.240.0060.01214.83
7.2.230.0090.00515.03
7.2.220.0070.00815.11
7.2.210.0040.01014.97
7.2.200.0100.00414.94
7.2.190.0070.00814.92
7.2.180.0070.00714.99
7.2.170.0110.00614.98
7.2.160.0070.00715.05
7.2.150.0070.00717.04
7.2.140.0090.00616.95
7.2.130.0030.00917.00
7.2.120.0030.01016.80
7.2.110.0110.00417.06
7.2.100.0030.01016.93
7.2.90.0100.00616.70
7.2.80.0060.00916.98
7.2.70.0040.01117.06
7.2.60.0070.00716.99
7.2.50.0070.00416.95
7.2.40.0650.01017.65
7.2.30.0290.00817.34
7.2.20.0280.00817.23
7.2.10.0360.00917.36
7.2.00.0500.00717.63
7.1.330.0050.00915.72
7.1.320.0080.00715.93
7.1.310.0050.00915.93
7.1.300.0030.00915.84
7.1.290.0040.01015.66
7.1.280.0090.00415.87
7.1.270.0030.01215.80
7.1.260.0050.00815.85
7.1.250.0060.00315.66
7.1.240.0030.01015.93
7.1.230.0070.00415.91
7.1.220.0060.01015.95
7.1.210.0110.00715.72
7.1.200.0090.00515.76
7.1.190.0000.01315.93
7.1.180.0040.01115.55
7.1.170.0070.00715.54
7.1.160.0520.01116.35
7.1.150.0280.00916.28
7.1.140.0410.00416.33
7.1.130.0440.00816.33
7.1.120.0640.01016.34
7.1.110.0390.01016.01
7.1.100.0360.00616.10
7.1.90.0480.00615.99
7.1.80.0410.01015.87
7.1.70.0580.01115.60
7.1.60.0450.00924.55
7.1.50.0440.01024.44
7.1.40.0590.00924.19
7.1.30.0490.01224.39
7.1.20.0520.00724.35
7.1.10.0300.00915.40
7.1.00.0530.01015.32
7.0.330.0060.00915.38
7.0.320.0040.01215.18
7.0.310.0060.00615.32
7.0.300.0060.00315.34
7.0.290.0030.00915.55
7.0.280.0090.00615.26
7.0.270.0040.00815.33
7.0.260.0040.00815.63
7.0.250.0030.01315.42
7.0.240.0120.00015.52
7.0.230.0000.00815.49
7.0.220.0030.01015.47
7.0.210.0000.01515.52
7.0.200.0000.01015.25
7.0.190.0090.00015.50
7.0.180.0070.00715.48
7.0.170.0160.00015.63
7.0.160.0040.01115.33
7.0.150.0030.00715.41
7.0.140.0060.00615.27
7.0.130.0070.00415.51
7.0.120.0110.00315.40
7.0.110.0050.00415.57
7.0.100.0070.01015.23
7.0.90.0040.01115.29
7.0.80.0090.00315.43
7.0.70.0000.01415.54
7.0.60.0070.00715.44
7.0.50.0090.00615.50
7.0.40.0080.00413.62
7.0.30.0090.00413.49
7.0.20.0030.01313.59
7.0.10.0030.01413.63
7.0.00.0040.00713.26
5.6.400.0000.01314.13
5.6.390.0070.00714.04
5.6.380.0110.00714.76
5.6.370.0090.00614.13
5.6.360.0030.00614.36
5.6.350.0100.00314.52
5.6.340.0000.01514.64
5.6.330.0120.00314.23
5.6.320.0030.00714.39
5.6.310.0060.00914.52
5.6.300.0030.00714.42
5.6.290.0080.00814.37
5.6.280.0070.00714.55
5.6.270.0070.00714.44
5.6.260.0090.00314.18
5.6.250.0030.01514.42
5.6.240.0030.00714.38
5.6.230.0050.00814.16
5.6.220.0000.01414.27
5.6.210.0030.00614.45
5.6.200.0000.01814.09
5.6.190.0030.00914.35
5.6.180.0030.01014.53
5.6.170.0100.00714.44
5.6.160.0100.00714.37
5.6.150.0000.01414.54
5.6.140.0030.00914.02
5.6.130.0070.00314.78
5.6.120.0100.00314.25
5.6.110.0000.01014.26
5.6.100.0040.01114.51
5.6.90.0130.00314.34
5.6.80.0000.01014.23
5.6.70.0030.01414.14
5.6.60.0040.01114.46
5.6.50.0090.00314.12
5.6.40.0060.00914.40
5.6.30.0030.00714.54
5.6.20.0090.00014.45
5.6.10.0050.00514.54
5.6.00.0030.00714.13

preferences:
59.38 ms | 400 KiB | 5 Q