3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* readonly */ class ImmutableCounter { public function __construct(private readonly int $count) {} public function add1(): self { return new self($this->count + 1); } public function value(): int { return $this->count; } } // assuming the proposed RFC is in place, this is now possible: class MutableCounter extends ImmutableCounter { public function __construct(private int $count) {} public function add1(): self { return new self(++$this->count); } public function value(): int { return $this->count; } } $counter1 = new ImmutableCounter(0); $counter2 = $counter1->add1(); $counter3 = $counter2->add1(); var_dump([$counter1->value(), $counter2->value(), $counter3->value()]); $mutableCounter1 = new MutableCounter(0); $mutableCounter2 = $mutableCounter1->add1(); $mutableCounter3 = $mutableCounter2->add1(); var_dump([$mutableCounter1->value(), $mutableCounter2->value(), $mutableCounter3->value()]);

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.0120.00520.60
8.4.110.0060.00518.75
8.4.100.0100.01017.72
8.4.90.0040.00517.73
8.4.80.0090.00717.93
8.4.70.0070.00417.86
8.4.60.0090.00818.82
8.4.50.0120.00517.65
8.4.40.0100.01019.43
8.4.30.0070.01019.02
8.4.20.0130.00318.11
8.4.10.0060.00323.97
8.3.250.0100.00820.98
8.3.240.0110.00816.70
8.3.230.0060.00216.64
8.3.220.0020.00716.99
8.3.210.0080.01116.70
8.3.200.0050.00416.29
8.3.190.0120.00620.66
8.3.180.0130.00716.74
8.3.170.0100.01017.29
8.3.160.0090.00917.07
8.3.150.0030.01517.38
8.3.140.0120.00617.03
8.3.130.0040.00418.48
8.3.120.0090.00618.94
8.3.110.0100.01016.70
8.3.100.0110.01116.53
8.3.50.0030.01318.56
8.2.290.0120.00720.73
8.2.280.0070.00518.49
8.2.270.0110.00716.62
8.2.260.0060.00316.55
8.2.250.0040.01118.53
8.2.240.0060.00317.17
8.2.230.0060.00318.31
8.2.220.0060.00316.50
8.1.330.0110.00722.08
8.1.320.0090.00716.22
8.1.310.0070.00718.25
8.1.300.0040.01519.70
8.1.120.0080.00818.64
8.1.110.0150.00018.60
8.1.100.0090.00618.60
8.1.90.0060.00918.64
8.1.80.0120.00318.70
8.1.70.0100.00718.64
8.1.60.0080.00818.84
8.1.50.0040.00418.78
8.1.40.0050.00318.68
8.1.30.0080.00718.90
8.1.20.0120.00618.90
8.1.10.0180.00018.73
8.1.00.0180.00018.68
8.0.250.0060.00318.07
8.0.240.0150.00018.11
8.0.230.0100.00517.96
8.0.220.0080.00817.94
8.0.210.0080.00817.98
8.0.200.0110.00518.05
8.0.190.0150.00018.04
8.0.180.0130.00317.94
8.0.170.0110.00418.09
8.0.160.0070.00717.94
8.0.150.0120.00318.06
8.0.140.0150.00017.86
8.0.130.0100.00618.04
8.0.120.0050.01017.84
8.0.110.0140.00017.98
8.0.100.0080.00817.98
8.0.90.0140.00017.95
8.0.80.0050.01117.97
8.0.70.0120.00318.02
8.0.60.0130.00218.02
8.0.50.0100.00517.84
8.0.30.0080.00817.96
8.0.20.0100.00518.10
8.0.10.0070.00718.10
7.4.330.0000.00614.65
7.4.320.0120.00417.42
7.4.300.0070.01017.38
7.4.290.0070.00317.51
7.4.280.0110.00617.51
7.4.270.0130.00217.44
7.4.260.0130.00317.55
7.4.250.0110.00617.43
7.4.240.0140.00317.57
7.4.230.0110.00717.61
7.4.220.0070.00717.55
7.4.210.0130.00317.41
7.4.200.0120.00417.55
7.4.190.0110.00417.47
7.4.180.0090.00617.50
7.4.160.0050.00917.44
7.4.150.0140.00017.56
7.4.140.0140.00017.36
7.4.130.0120.00317.25
7.4.120.0150.00017.38
7.4.110.0090.00617.37
7.4.100.0080.00717.39
7.4.90.0150.00017.22
7.4.80.0050.01017.31
7.4.70.0070.00717.43
7.4.60.0100.00317.28
7.4.50.0110.00417.15
7.4.40.0100.00017.18
7.4.30.0080.00517.42
7.4.20.0050.00517.34
7.4.10.0050.00717.29
7.4.00.0060.00617.29

preferences:
28.63 ms | 403 KiB | 5 Q