3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); abstract class AbstractWorker{ public $rank; public $isBoss; public $count; public $coffee; public $salary; public $pages; public function __construct($count, $rank, $isBoss) { $this->rank = $rank; $this->count = $count; $this->isBoss = $isBoss; } public function CalculationOfInformation($rank, $isBoss){ if ($this->rank == 2){ $this->salary = $this->salary * 1.25 * $this->count; } elseif ($this->rank == 3){ $this->salary = $this->salary * 1.5 * $this->count; } else { $this->salary = $this->salary * $this->count; } $this->coffee = $this->coffee * $this->count; $this->pages = $this->pages * $this->count; if ($this->isBoss == 1){ $this->salary *= 1.5; $this->coffee *= 2; $this->pages = 0; } } public function getInformation($value){ return $value; } } class Manager extends AbstractWorker{ public $coffee = 20; public $salary = 500; public $pages = 200; } class Marketer extends AbstractWorker{ public $coffee = 15; public $salary = 400; public $pages = 150; } class Engineer extends AbstractWorker{ public $coffee = 5; public $salary = 200; public $pages = 50; } class Analyst extends AbstractWorker{ public $coffee = 50; public $salary = 800; public $pages = 5; } class Department{ public $name; public $workers = array(); public function __construct($name) { $this->name = $name; } public function addWorkers(AbstractWorker $worker){ $worker->CalculationOfInformation($worker->rank, $worker->isBoss); $this->workers[] = $worker; } public function getInformarion (){ $informarion = array($this->name, 0, 0, 0, 0, 0); foreach ($this->workers as $worker) { $informarion[1] += $worker->getInformation($worker->count); $informarion[2] += $worker->getInformation($worker->salary); $informarion[3] += $worker->getInformation($worker->coffee); $informarion[4] += $worker->getInformation($worker->pages); } $informarion[5] = round($informarion[2] / $informarion[4], 1); return $informarion; } } class Company{ public $departments = array(); public function addDepartment(Department $department){ $this->departments[] = $department; } public function padLeft($value, $columnLength){ echo $value; echo str_repeat(" ", $columnLength - mb_strlen($value)); } public function calculatiotOfOutput(array $informarion){ $col1 = 15; $col2 = 10; $col3 = 10; $col4 = 8; $col5 = 8; $col6 = 15; echo $this->padLeft($informarion[0], $col1) . $this->padLeft($informarion[1], $col2) . $this->padLeft($informarion[2], $col3) . $this->padLeft($informarion[3], $col4) . $this->padLeft($informarion[4], $col5) . $this->padLeft($informarion[5], $col6) . "\n"; } public function printInformationOfDepartment(){ $columbNames = array("Департамент", "сотр.", "тугр.", "кофе", "стр.", "тугр./стр."); $this->calculatiotOfOutput($columbNames); echo "\n"; foreach ($this->departments as $department) { $informarion = $department->getInformarion(); $this->calculatiotOfOutput($informarion); } echo "\n"; $totalInformation = array("", 0, 0, 0, 0, 0); foreach ($this->departments as $department) { $informarion = $department->getInformarion(); $totalInformation[1] += $informarion[1]; $totalInformation[2] += $informarion[2]; $totalInformation[3] += $informarion[3]; $totalInformation[4] += $informarion[4]; $totalInformation[5] += $informarion[5]; } $totalInformation[0] = "Всего"; $averageInformation = array("", 0, 0, 0, 0, 0); for ($i = 1; $i < 6; $i++){ $averageInformation[$i] = $totalInformation[$i] / count($this->departments); } $averageInformation[0] = "Среднее"; $this->calculatiotOfOutput($averageInformation); $this->calculatiotOfOutput($totalInformation); } } $vektor = new Company; $vektor->addDepartment(new $procurementDepartment("Закупок")); $vektor->addDepartment(new $sellingDepartment("Продаж")); //$procurementDepartment = new Department("Закупок"); // $procurementDepartment->addWorkers(new Manager(14, 1, 0)); // $procurementDepartment->addWorkers(new Manager(10, 2, 0)); //$sellingDepartment = new Department("Продаж"); // $sellingDepartment->addWorkers(new Manager(5, 1, 0)); // $vektor->addDepartment($procurementDepartment); // $vektor->addDepartment($sellingDepartment); //$vektor->printInformationOfDepartment();

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.70.0120.00316.75
8.3.60.0040.01117.00
8.3.50.0110.00716.73
8.3.40.0150.00018.87
8.3.30.0160.00018.98
8.3.20.0080.00020.35
8.3.10.0060.00323.67
8.3.00.0040.00423.71
8.2.190.0080.00817.00
8.2.180.0090.00916.75
8.2.170.0120.00322.96
8.2.160.0030.01220.70
8.2.150.0050.00325.66
8.2.140.0060.00324.66
8.2.130.0040.00422.18
8.2.120.0040.00426.35
8.2.110.0070.00322.20
8.2.100.0110.00017.70
8.2.90.0000.00818.03
8.2.80.0040.00417.97
8.2.70.0000.00917.50
8.2.60.0040.00417.80
8.2.50.0040.00718.10
8.2.40.0040.00422.33
8.2.30.0000.00819.25
8.2.20.0050.00318.06
8.2.10.0050.00218.00
8.2.00.0000.00718.11
8.1.280.0140.01025.92
8.1.270.0050.00324.01
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00323.65
8.1.230.0090.00321.11
8.1.220.0040.00417.74
8.1.210.0080.00018.84
8.1.200.0070.00417.25
8.1.190.0030.00617.48
8.1.180.0030.00518.10
8.1.170.0040.00418.71
8.1.160.0040.00418.95
8.1.150.0050.00318.65
8.1.140.0040.00417.77
8.1.130.0040.00418.82
8.1.120.0000.00817.39
8.1.110.0040.00417.50
8.1.100.0000.00817.36
8.1.90.0070.00017.42
8.1.80.0050.00317.40
8.1.70.0050.00317.46
8.1.60.0030.00617.57
8.1.50.0040.00417.57
8.1.40.0050.00317.50
8.1.30.0050.00317.59
8.1.20.0060.00317.62
8.1.10.0030.00517.72
8.1.00.0090.00017.58
8.0.300.0000.00820.33
8.0.290.0080.00016.88
8.0.280.0070.00018.46
8.0.270.0030.00617.21
8.0.260.0000.00816.77
8.0.250.0030.00316.90
8.0.240.0000.00716.95
8.0.230.0030.00316.95
8.0.220.0000.00916.93
8.0.210.0030.00316.95
8.0.200.0000.00717.00
8.0.190.0040.00416.99
8.0.180.0070.00317.05
8.0.170.0040.00417.01
8.0.160.0040.00416.98
8.0.150.0040.00416.81
8.0.140.0040.00416.92
8.0.130.0000.00513.48
8.0.120.0040.00416.90
8.0.110.0050.00216.77
8.0.100.0040.00416.84
8.0.90.0040.00416.97
8.0.80.0070.00716.89
8.0.70.0040.00416.97
8.0.60.0050.00316.83
8.0.50.0030.00516.79
8.0.30.0080.01017.30
8.0.20.0100.01117.41
8.0.10.0050.00217.16
8.0.00.0090.00917.03
7.4.330.0060.00016.69
7.4.320.0050.00216.61
7.4.300.0000.00616.62
7.4.290.0040.00416.57
7.4.280.0040.00416.71
7.4.270.0070.00016.54
7.4.260.0000.00816.69
7.4.250.0000.00716.55
7.4.240.0000.00716.71
7.4.230.0040.00316.42
7.4.220.0120.01516.59
7.4.210.0030.01216.69
7.4.200.0040.00416.48
7.4.160.0050.01516.46
7.4.150.0110.00717.40
7.4.140.0080.01417.86
7.4.130.0100.00716.64
7.4.120.0080.01216.64
7.4.110.0070.01016.52
7.4.100.0070.01016.61
7.4.90.0000.01816.52
7.4.80.0100.01019.39
7.4.70.0070.01016.66
7.4.60.0000.01616.60
7.4.50.0100.00716.56
7.4.40.0120.01216.61
7.4.30.0140.00716.65
7.4.00.0040.01115.03
7.3.330.0030.00313.32
7.3.320.0060.00013.46
7.3.310.0030.00316.64
7.3.300.0000.00716.41
7.3.290.0030.00316.57
7.3.280.0090.00816.50
7.3.270.0060.01317.40
7.3.260.0140.00716.60
7.3.250.0070.01216.51
7.3.240.0070.01116.47
7.3.230.0060.01516.64
7.3.210.0060.01516.42
7.3.200.0100.00716.45
7.3.190.0100.00716.69
7.3.180.0030.01316.39
7.3.170.0100.00716.50
7.3.160.0030.01316.50
7.3.120.0100.00614.97
7.3.110.0060.00615.07
7.3.100.0030.01714.96
7.3.90.0040.01214.84
7.3.80.0030.01214.64
7.3.70.0120.00615.02
7.3.60.0030.01314.77
7.3.50.0070.00714.77
7.3.40.0000.01414.99
7.3.30.0040.01114.84
7.3.20.0040.01216.64
7.3.10.0080.00816.60
7.3.00.0030.01016.54
7.2.330.0160.00316.67
7.2.320.0070.01116.43
7.2.310.0090.00916.81
7.2.300.0080.00916.64
7.2.290.0040.01316.64
7.2.240.0000.01315.12
7.2.230.0070.00714.84
7.2.220.0100.00714.96
7.2.210.0030.00814.82
7.2.200.0070.01314.92
7.2.190.0070.01014.95
7.2.180.0040.00715.08
7.2.170.0040.00715.08
7.2.160.0130.00314.96
7.2.150.0040.01516.64
7.2.140.0000.01216.88
7.2.130.0060.00716.77
7.2.120.0160.00016.55
7.2.110.0000.01616.82
7.2.100.0030.00816.66
7.2.90.0000.01416.58
7.2.80.0070.01016.95
7.2.70.0090.00616.64
7.2.60.0070.00316.79
7.2.50.0140.00316.91
7.2.40.0060.01216.91
7.2.30.0070.01016.88
7.2.20.0080.01016.74
7.2.10.0110.00716.76
7.2.00.0000.01916.61
7.1.330.0060.01115.70
7.1.320.0030.01015.81
7.1.310.0030.01115.86
7.1.300.0000.01315.38
7.1.290.0140.00315.39
7.1.280.0040.01115.86
7.1.270.0060.00615.77
7.1.260.0060.00915.75
7.1.250.0060.01015.76
7.1.200.0030.00815.86
7.1.110.0130.00617.97
7.1.100.0060.01017.92
7.1.90.0060.00618.31
7.1.80.0060.00617.71
7.1.70.0030.00917.09
7.1.60.0210.00634.80
7.1.50.0160.01934.70
7.1.40.0090.01934.39
7.1.30.0100.01734.39
7.1.20.0180.00734.55
7.1.10.0030.01016.61
7.1.00.0000.01316.52
7.0.250.0090.00617.38
7.0.240.0030.01317.79
7.0.230.0070.00717.70
7.0.220.0000.01217.99
7.0.210.0060.00616.58
7.0.200.0040.01316.57
7.0.190.0130.00316.55
7.0.180.0030.01016.30
7.0.170.0060.00616.13
7.0.160.0060.00616.23
7.0.150.0030.00916.25
7.0.140.0000.01216.21
7.0.130.0000.01316.42
7.0.120.0060.00916.48
7.0.110.0030.01016.05
7.0.100.0100.00616.38
7.0.90.0060.00916.44
7.0.80.0040.01216.25
7.0.70.0040.01316.40
7.0.60.0090.00615.97
7.0.50.0090.00616.21
7.0.40.0060.00916.64
7.0.30.0070.00716.36
7.0.20.0030.01216.20
7.0.10.0060.01016.28
7.0.00.0060.00916.37

preferences:
69.69 ms | 401 KiB | 5 Q