3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface MushroomCalculatorInterface { public function calculateDosage($dose, $wetOrFresh, $MAOi); } class MushroomCalculatorFactory { private $strains = []; private $calculator; public function __construct($strains, $calculator) { $this->strains = $strains; $this->calculator = $calculator; } public function createMushroomCalculator($name): MushroomCalculatorInterface { $potency = $this->strains[$name]; return new $this->calculator($name, $potency); } } class MushroomCalculator implements MushroomCalculatorInterface { private $name; private $potency; public function __construct($name, $potency) { $this->name = $name; $this->potency = $potency; } public function calculateDosage($dose, $wetOrFresh, $MAOi) { $dosages = [ 'microdose' => 0.25, 'regular' => 2.5, 'heroic' => 5, ]; # Pick a dose $dosage = $dosages[$dose]; if ($wetOrFresh) { $dosage *= 9.3; } if ($MAOi) { $dosage /= 2; } return round(($dosage / $this->factor($this->potency)), 2); } private function factor($potency) { $cubensis = 0.63; return $potency / $cubensis; } } $strains = [ 'azurenscens' => 1.78, 'baeocystis' => .85, 'bohemica' => 1.34, 'cubensis' => .63, 'cyanescens' => .85, 'cyanofibrillosa' => .21, 'hoogshagenii' => .60, 'liniformans' => .16, 'penis envy' => 1.35, 'semilanceata' => .98, 'stuntzii' => .36, 'tampanensis' => .68, 'weilii' => .61, ]; #$factory= new MushroomCalculatorFactory($strains, MushroomCalculator::class); $name = 'azurenscens'; $potency = $strains['azurenscens']; # foreach (mushroom) { #$calculator = $factory->createMushroomCalculator('azurenscens'); $calculator = new MushroomCalculator($name, $potency); echo $calculator->calculateDosage('heroic', true, true); # }

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.0090.00918.33
8.3.50.0080.01517.40
8.3.40.0090.00618.84
8.3.30.0120.00918.97
8.3.20.0040.00421.96
8.3.10.0040.00420.10
8.3.00.0080.00021.74
8.2.180.0110.01125.92
8.2.170.0110.00419.08
8.2.160.0100.00320.38
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0030.00726.16
8.2.120.0080.00021.13
8.2.110.0000.01021.11
8.2.100.0060.00617.84
8.2.90.0000.00718.47
8.2.80.0040.00417.97
8.2.70.0000.00918.16
8.2.60.0060.00318.22
8.2.50.0050.00318.10
8.2.40.0030.00619.52
8.2.30.0000.00820.40
8.2.20.0000.00718.21
8.2.10.0040.00419.27
8.2.00.0000.00818.07
8.1.280.0070.00725.92
8.1.270.0000.00824.66
8.1.260.0030.00526.35
8.1.250.0050.00328.09
8.1.240.0060.00322.54
8.1.230.0040.00721.10
8.1.220.0040.00417.78
8.1.210.0080.00018.99
8.1.200.0060.00317.48
8.1.190.0030.00517.23
8.1.180.0050.00318.10
8.1.170.0030.00618.59
8.1.160.0000.00718.98
8.1.150.0040.00418.88
8.1.140.0000.00818.99
8.1.130.0030.00619.29
8.1.120.0000.00817.53
8.1.110.0040.00417.51
8.1.100.0080.00017.53
8.1.90.0030.00617.54
8.1.80.0000.00717.60
8.1.70.0050.00317.57
8.1.60.0070.00317.67
8.1.50.0040.00417.52
8.1.40.0050.00317.65
8.1.30.0000.00917.68
8.1.20.0030.00617.63
8.1.10.0000.00717.65
8.1.00.0040.00417.58
8.0.300.0000.00820.11
8.0.290.0040.00416.88
8.0.280.0000.00718.49
8.0.270.0000.00818.67
8.0.260.0030.00316.80
8.0.250.0000.01016.94
8.0.240.0030.00316.97
8.0.230.0000.00717.05
8.0.220.0030.00317.02
8.0.210.0000.00717.00
8.0.200.0030.00316.90
8.0.190.0040.00416.97
8.0.180.0040.00416.84
8.0.170.0000.00816.95
8.0.160.0000.00817.10
8.0.150.0030.00616.76
8.0.140.0000.00816.88
8.0.130.0030.00313.41
8.0.120.0040.00416.98
8.0.110.0040.00417.01
8.0.100.0070.00016.79
8.0.90.0000.00716.88
8.0.80.0070.01116.96
8.0.70.0050.00316.94
8.0.60.0000.00717.01
8.0.50.0000.00716.92
8.0.30.0080.00917.21
8.0.20.0180.00417.19
8.0.10.0040.00417.21
8.0.00.0110.01016.94
7.4.330.0060.00015.55
7.4.320.0000.00716.70
7.4.300.0060.00016.71
7.4.290.0000.00716.50
7.4.280.0070.00016.64
7.4.270.0070.00016.60
7.4.260.0000.00816.73
7.4.250.0000.00716.63
7.4.240.0000.00816.58
7.4.230.0070.00016.62
7.4.220.0040.00416.69
7.4.210.0070.00816.65
7.4.200.0040.00416.58
7.4.160.0090.00916.57
7.4.130.0080.01516.63
7.4.120.0090.00916.66
7.4.110.0090.00816.51
7.4.100.0140.00516.73
7.4.90.0080.01116.67
7.4.80.0090.00919.39
7.4.70.0130.00316.59
7.4.60.0030.01516.72
7.4.50.0030.01016.57
7.4.40.0080.00816.53
7.4.10.0090.00915.20
7.4.00.0080.01014.87
7.3.330.0000.00613.27
7.3.320.0000.00713.51
7.3.310.0000.00816.39
7.3.300.0000.00816.27
7.3.290.0140.00016.41
7.3.280.0100.00416.43
7.3.260.0130.00716.52
7.3.240.0090.01116.55
7.3.230.0080.00816.45
7.3.210.0100.00716.65
7.3.200.0100.00616.38
7.3.190.0080.01116.70
7.3.180.0110.00416.38
7.3.170.0000.01616.47
7.3.160.0040.01216.45
7.3.130.0030.01015.17
7.3.120.0070.01215.11
7.3.110.0100.00914.67
7.3.100.0050.00914.79
7.3.90.0040.01114.80
7.3.80.0080.00815.13
7.3.70.0070.00714.86
7.3.60.0130.00214.98
7.3.50.0070.00914.88
7.3.40.0070.00714.95
7.3.30.0060.01114.68
7.3.20.0050.00816.64
7.3.10.0050.00916.45
7.3.00.0050.00616.63
7.2.330.0180.00016.86
7.2.320.0070.01516.63
7.2.310.0100.00716.56
7.2.300.0000.01616.72
7.2.290.0070.01116.76
7.2.260.0070.01115.07
7.2.250.0100.00715.07
7.2.240.0070.00814.99
7.2.230.0090.00715.22
7.2.220.0050.01014.95
7.2.210.0030.01215.10
7.2.200.0050.01015.10
7.2.190.0070.00915.06
7.2.180.0130.00414.98
7.2.170.0020.01215.02
7.2.160.0050.01015.02
7.2.150.0070.00716.85
7.2.140.0040.00716.81
7.2.130.0070.01016.95
7.2.120.0090.00316.93
7.2.110.0060.00816.93
7.2.100.0070.01016.96
7.2.90.0050.01016.85
7.2.80.0050.01016.73
7.2.70.0100.00516.97
7.2.60.0060.00716.95
7.2.50.0050.01017.06
7.2.40.0020.01117.01
7.2.30.0070.00817.00
7.2.20.0080.00516.97
7.2.10.0050.00917.06
7.2.00.0060.00617.00
7.1.330.0080.00815.74
7.1.320.0050.01015.63
7.1.310.0050.01115.71
7.1.300.0120.00315.81
7.1.290.0030.00915.72
7.1.280.0050.01115.61
7.1.270.0070.00815.74
7.1.260.0030.00815.76
7.1.250.0060.00615.92
7.1.240.0030.01015.74
7.1.230.0080.00615.96
7.1.220.0070.00115.82
7.1.210.0030.00915.72
7.1.200.0060.00615.77
7.1.190.0020.00615.77
7.1.180.0060.00615.92
7.1.170.0050.00715.78
7.1.160.0070.00515.87
7.1.150.0080.00615.83
7.1.140.0050.00815.85
7.1.130.0050.01015.73
7.1.120.0090.00115.88
7.1.110.0060.00515.94
7.1.100.0080.00715.85
7.1.90.0050.00915.98
7.1.80.0030.00915.81
7.1.70.0000.01116.00
7.1.60.0030.01115.68
7.1.50.0100.00615.77
7.1.40.0060.00915.90
7.1.30.0080.00815.58
7.1.20.0080.00815.86
7.1.10.0040.00715.89
7.1.00.0020.01015.62

preferences:
62.32 ms | 401 KiB | 5 Q