3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Forest { public function treesHeight(): float; } final class EarthForest implements Forest { public function treesHeight(): float { return 123 * 456; } } interface Plains { public function windPower(): float; } final class EarthPlains implements Plains { public function windPower(): float { return 10; } } final class MarsPlains implements Plains { public function windPower(): float { return 250; } } interface Sea { public function noise(): string; } final class EarthSea implements Sea { public function noise(): string { return 'Shush! Shush!'; } } interface TerrainFactory { public function makeSea(): Sea; public function makeForest(): Forest; public function makePlains(): Plains; } final class EarthTerrainFactory implements TerrainFactory { public function makeForest(): EarthForest { return new EarthForest(); } public function makePlains(): EarthPlains { return new EarthPlains(); } public function makeSea(): EarthSea { return new EarthSea(); } } // boilerplate code for null case final class NullForest implements Forest { public function treesHeight(): float { return 0.; } } final class NullPlains implements Plains { public function windPower(): float { return 0.; } } final class NullSea implements Sea { public function noise(): string { return ''; } } final class NullTerrainFactory implements TerrainFactory { public function makeForest(): NullForest { return new NullForest(); } public function makePlains(): NullPlains { return new NullPlains(); } public function makeSea(): NullSea { return new NullSea(); } } // end boilerplate code class TerrainFactoryFactory { public function make(string $type) { return match($type) { 'earth' => new EarthTerrainFactory(), default => new NullTerrainFactory(), }; } } $type = 'earth'; $factoryFactory = new TerrainFactoryFactory(); $terrainFactory = $factoryFactory->make($type); $forest = $terrainFactory->makeForest(); $plains = $terrainFactory->makePlains(); $sea = $terrainFactory->makeSea(); var_dump($forest->treesHeight()); var_dump($plains->windPower()); var_dump($sea->noise());

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.01020.94
8.4.110.0100.01118.77
8.4.100.0090.00118.05
8.4.90.0140.00718.01
8.4.80.0120.00818.10
8.4.70.0140.00618.01
8.4.60.0110.00918.70
8.4.50.0100.01018.00
8.4.40.0090.00917.88
8.4.30.0000.00820.41
8.4.20.0110.01117.82
8.4.10.0130.00319.32
8.3.250.0120.00718.80
8.3.240.0110.00816.63
8.3.230.0120.00716.61
8.3.220.0090.00717.16
8.3.210.0110.00816.64
8.3.200.0080.00416.77
8.3.190.0130.00616.48
8.3.180.0020.00616.61
8.3.170.0040.00716.80
8.3.160.0160.00318.57
8.3.150.0090.00917.20
8.3.140.0060.00316.63
8.3.130.0130.00316.47
8.3.120.0050.00519.13
8.3.110.0080.00018.39
8.3.100.0120.00618.66
8.3.90.0080.00026.77
8.3.80.0000.01019.36
8.3.70.0110.00718.30
8.3.60.0060.00918.43
8.3.50.0120.00724.49
8.3.40.0070.01421.81
8.3.30.0110.00418.72
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0030.00526.16
8.2.290.0080.01120.38
8.2.280.0090.00518.57
8.2.270.0120.00616.56
8.2.260.0030.00618.27
8.2.250.0060.00316.49
8.2.240.0030.00519.19
8.2.230.0080.00020.94
8.2.220.0060.00324.06
8.2.210.0120.00326.77
8.2.200.0040.00418.88
8.2.190.0090.00616.78
8.2.180.0070.01425.92
8.2.170.0110.00719.13
8.2.160.0130.00622.96
8.2.150.0000.00725.66
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0040.00419.36
8.2.110.0090.00020.52
8.2.100.0110.00018.97
8.1.330.0110.00718.17
8.1.320.0120.00716.38
8.1.310.0080.00016.65
8.1.300.0000.00718.51
8.1.290.0060.00330.84
8.1.280.0100.00725.92
8.1.270.0050.00323.99
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0000.01118.48
8.1.230.0070.00318.48
7.4.120.0140.00716.27
7.4.110.0080.01116.39
7.4.100.0110.01016.13
7.4.90.0080.01116.37
7.4.80.0100.00916.41
7.4.70.0110.01016.31
7.4.60.0130.00916.34
7.4.50.0060.01516.25
7.4.40.0120.00616.42
7.4.30.0090.01116.29
7.4.20.0170.00316.08
7.4.10.0160.00416.31
7.4.00.0060.01216.28
7.3.240.0140.00516.12
7.3.230.0100.01016.27
7.3.220.0100.00816.28
7.3.210.0110.00716.25
7.3.200.0090.01216.20
7.3.190.0090.01116.34
7.3.180.0060.01216.29
7.3.170.0100.01016.26
7.3.160.0090.01016.29
7.3.150.0060.01316.15
7.3.140.0100.01016.07
7.3.130.0100.00916.18
7.3.120.0050.01516.06
7.3.110.0100.01216.13
7.3.100.0110.00816.30
7.3.90.0120.00716.23
7.3.80.0080.01316.17
7.3.70.0100.01116.17
7.3.60.0080.00916.19
7.3.50.0120.00516.10
7.3.40.0120.00416.25
7.3.30.0110.00916.21
7.3.20.0150.01016.16
7.3.10.0170.00416.26
7.3.00.0110.00816.16
7.2.340.0110.01016.38
7.2.330.0120.00716.41
7.2.320.0150.00816.39
7.2.310.0130.00616.40
7.2.300.0120.00916.23
7.2.290.0140.00516.29
7.2.280.0100.00816.24
7.2.270.0120.00716.44
7.2.260.0080.01016.16
7.2.250.0130.01316.33
7.2.240.0060.01216.54
7.2.230.0070.01316.28
7.2.220.0090.01216.17
7.2.210.0110.01016.15
7.2.200.0060.01516.51
7.2.190.0110.00816.43
7.2.180.0110.00716.21
7.2.170.0140.00616.26
7.2.160.0020.01816.30
7.2.150.0260.01316.28
7.2.140.0170.00616.29
7.2.130.0060.01216.37
7.2.120.0060.01416.41
7.2.110.0070.01316.49
7.2.100.0120.00616.53
7.2.90.0100.00816.39
7.2.80.0130.00616.40
7.2.70.0100.00816.44
7.2.60.0090.01016.26
7.2.50.0180.00416.40
7.2.40.0130.00616.36
7.2.30.0140.00516.46
7.2.20.0140.00716.32
7.2.10.0090.01216.33
7.2.00.0050.01316.36

preferences:
69.01 ms | 403 KiB | 5 Q