3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeService { public string $something; } // before, in 10.1 class BaseOld { protected SomeService $test; public function __construct(?SomeService $test = NULL) { if ($test === NULL) { $test = new SomeService(); $test->something = 'fallback'; } $this->test = $test; } public function printTest(): void { print __CLASS__ . "\t" . $this->test->something . "\n"; } } // after class BaseNew { private SomeService $test; public function __construct(?SomeService $test = NULL) { if ($test === NULL) { $test = new SomeService(); $test->something = 'fallback'; } $this->test = $test; } public function printTest(): void { print __CLASS__ . "\t" . $this->test->something . "\n"; } } //NOTE: IDENTICAL! // class FooOld extends BaseOld { // protected $test; // public function __construct() { // parent::__construct(); // $this->test = new SomeService(); // $this->test->something = 'subclass'; // } // } class FooNew extends BaseNew { protected $test; public function __construct() { parent::__construct(); $this->test = new SomeService(); $this->test->something = 'subclass'; } } // $f = new FooOld(); // $f->printTest(); $f = new FooNew(); $f->printTest();

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.0090.01123.95
8.4.110.0090.01119.07
8.4.100.0040.00618.75
8.4.90.0110.01020.48
8.4.80.0080.01318.63
8.4.70.0120.00419.12
8.4.60.0110.00818.65
8.4.50.0120.00818.77
8.4.40.0030.01617.36
8.4.30.0130.00618.96
8.4.20.0140.00719.48
8.4.10.0030.00519.40
8.3.250.0090.00518.88
8.3.240.0130.01017.16
8.3.230.0130.00516.61
8.3.220.0100.00518.84
8.3.210.0120.00616.56
8.3.200.0060.00816.53
8.3.190.0100.00917.22
8.3.180.0100.00818.94
8.3.170.0140.00419.04
8.3.160.0120.00617.25
8.3.150.0090.00919.05
8.3.140.0030.00616.78
8.3.130.0060.00318.51
8.3.120.0030.00619.22
8.3.110.0060.00316.86
8.3.100.0000.00924.06
8.3.90.0080.00026.77
8.3.80.0040.00417.97
8.3.70.0140.00718.30
8.3.60.0120.00318.38
8.3.50.0040.01116.62
8.3.40.0040.01120.10
8.3.30.0170.00321.77
8.3.20.0050.00324.18
8.3.10.0040.00424.66
8.3.00.0030.01626.35
8.2.290.0120.00720.39
8.2.280.0130.00718.36
8.2.270.0070.01118.94
8.2.260.0140.00418.54
8.2.250.0030.00618.30
8.2.240.0040.00419.04
8.2.230.0040.00420.94
8.2.220.0050.00537.54
8.2.210.0000.01826.77
8.2.200.0060.00316.50
8.2.190.0090.00916.75
8.2.180.0090.00916.63
8.2.170.0150.00018.95
8.2.160.0030.01022.96
8.2.150.0050.00325.66
8.2.140.0090.00024.66
8.2.130.0140.00426.35
8.2.120.0150.00026.35
8.2.110.0100.00326.35
8.2.100.0000.00826.35
8.2.90.0080.00026.35
8.2.80.0040.00426.35
8.2.70.0030.00626.35
8.2.60.0080.00026.35
8.2.50.0050.00326.35
8.2.40.0060.00326.35
8.2.30.0050.00326.35
8.2.20.0030.00526.35
8.2.10.0080.00026.35
8.2.00.0030.00526.35
8.1.330.0140.00522.06
8.1.320.0120.00716.10
8.1.310.0060.00316.87
8.1.300.0040.00418.45
8.1.290.0040.00430.84
8.1.280.0120.00625.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0080.00026.35
8.1.240.0040.00426.35
8.1.230.0000.00826.35
8.1.220.0080.00026.35
8.1.210.0050.00326.35
8.1.200.0090.00026.35
8.1.190.0050.00326.35
8.1.180.0080.00026.35
8.1.170.0040.00426.35
8.1.160.0040.00426.35
8.1.150.0080.00026.35
8.1.140.0000.00826.35
8.1.130.0080.00026.35
8.1.120.0040.00426.35
8.1.110.0040.00426.35
8.1.100.0080.00026.35
8.1.90.0090.00026.35
8.1.80.0030.00626.35
8.1.70.0050.00326.35
8.1.60.0060.00326.35
8.1.50.0080.00026.35
8.1.40.0060.00326.35
8.1.30.0030.00526.35
8.1.20.0050.00326.35
8.1.10.0080.00026.35
8.1.00.0090.00026.35

preferences:
48.43 ms | 403 KiB | 5 Q