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; } private function padLeft($value, $columnLength){ echo $value; echo str_repeat(" ", $columnLength - mb_strlen($value)); } private function calculatiotOfOutput(array $informarion){ $col1 = 15; $col2 = 8; $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] = round($totalInformation[$i] / count($this->departments), 1); } $averageInformation[0] = "Среднее"; $this->calculatiotOfOutput($averageInformation); $this->calculatiotOfOutput($totalInformation); } } $vektor = new Company; $vektor->addDepartment(new Department("Закупок")); $vektor->addDepartment(new Department("Продаж")); $vektor->addDepartment(new Department("Рекламы")); $vektor->addDepartment(new Department("Логистики")); $vektor->departments[0]->addWorkers(new Manager(9, 1, 0)); $vektor->departments[0]->addWorkers(new Manager(3, 2, 0)); $vektor->departments[0]->addWorkers(new Manager(2, 3, 0)); $vektor->departments[0]->addWorkers(new Marketer(2, 1, 0)); $vektor->departments[0]->addWorkers(new Manager(1, 2, 1)); $vektor->departments[1]->addWorkers(new Manager(12, 1, 0)); $vektor->departments[1]->addWorkers(new Marketer(6, 1, 0)); $vektor->departments[1]->addWorkers(new Analyst(3, 1, 0)); $vektor->departments[1]->addWorkers(new Marketer(2, 2, 0)); $vektor->departments[1]->addWorkers(new Marketer(1, 2, 1)); $vektor->departments[2]->addWorkers(new Marketer(15, 1, 0)); $vektor->departments[2]->addWorkers(new Marketer(10, 2, 0)); $vektor->departments[2]->addWorkers(new Manager(8, 1, 0)); $vektor->departments[2]->addWorkers(new Engineer(2, 1, 0)); $vektor->departments[2]->addWorkers(new Marketer(1, 3, 1)); $vektor->departments[3]->addWorkers(new Manager(13, 1, 0)); $vektor->departments[3]->addWorkers(new Manager(5, 2, 0)); $vektor->departments[3]->addWorkers(new Engineer(5, 1, 0)); $vektor->departments[3]->addWorkers(new Manager(1, 1, 1)); $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.60.0090.00617.00
8.3.50.0150.00016.88
8.3.40.0130.00319.10
8.3.30.0160.00619.15
8.3.20.0000.00820.60
8.3.10.0070.01023.73
8.3.00.0040.01123.78
8.2.180.0110.01116.63
8.2.170.0100.01322.96
8.2.160.0030.01219.58
8.2.150.0100.00024.18
8.2.140.0030.00624.66
8.2.130.0090.00922.21
8.2.120.0040.00426.35
8.2.110.0040.00420.63
8.2.100.0090.00318.16
8.2.90.0040.00419.47
8.2.80.0050.00317.97
8.2.70.0030.00617.75
8.2.60.0030.00718.18
8.2.50.0080.00018.20
8.2.40.0060.00320.61
8.2.30.0040.00421.09
8.2.20.0040.00418.37
8.2.10.0030.00518.20
8.2.00.0040.00418.33
8.1.280.0100.00725.92
8.1.270.0080.00022.25
8.1.260.0000.00826.35
8.1.250.0070.01028.09
8.1.240.0050.00523.78
8.1.230.0040.00820.96
8.1.220.0000.01117.78
8.1.210.0000.00818.77
8.1.200.0030.00617.63
8.1.190.0000.00817.79
8.1.180.0000.00818.10
8.1.170.0000.00818.95
8.1.160.0030.00519.20
8.1.150.0040.00420.64
8.1.140.0000.00717.86
8.1.130.0050.00519.10
8.1.120.0040.00417.72
8.1.110.0050.00317.65
8.1.100.0040.00717.71
8.1.90.0000.00917.68
8.1.80.0040.00417.56
8.1.70.0030.00717.58
8.1.60.0000.00817.83
8.1.50.0050.00317.78
8.1.40.0040.00417.78
8.1.30.0030.00517.89
8.1.20.0040.00417.85
8.1.10.0030.00617.81
8.1.00.0090.00017.77
8.0.300.0040.00418.77
8.0.290.0060.00317.00
8.0.280.0040.00418.76
8.0.270.0040.00317.41
8.0.260.0030.00317.16
8.0.250.0050.00317.20
8.0.240.0070.00017.32
8.0.230.0070.00017.28
8.0.220.0080.00017.18
8.0.210.0030.00317.23
8.0.200.0000.00717.25
8.0.190.0000.00817.27
8.0.180.0040.00417.25
8.0.170.0050.00217.14
8.0.160.0040.00417.27
8.0.150.0000.00817.23
8.0.140.0030.00517.20
8.0.130.0060.00313.67
8.0.120.0000.00817.14
8.0.110.0080.00017.12
8.0.100.0040.00417.33
8.0.90.0040.00417.20
8.0.80.0110.00717.20
8.0.70.0030.00517.29
8.0.60.0000.00917.11
8.0.50.0030.00517.03
8.0.30.0110.00817.35
8.0.20.0130.00717.48
8.0.10.0030.00517.16
8.0.00.0030.01716.93
7.4.330.0050.00016.90
7.4.320.0000.00916.66
7.4.300.0000.00616.71
7.4.290.0050.00316.82
7.4.280.0030.00316.79
7.4.270.0000.00716.82
7.4.260.0040.00416.60
7.4.250.0050.00216.75
7.4.240.0000.00716.81
7.4.230.0040.00416.72
7.4.220.0110.01516.78
7.4.210.0090.00616.67
7.4.200.0040.00416.88
7.4.160.0140.00316.64
7.4.150.0120.00617.40
7.4.140.0110.01017.86
7.4.130.0070.01316.81
7.4.120.0120.01016.87
7.4.110.0070.01116.70
7.4.100.0090.00916.79
7.4.90.0130.00616.77
7.4.80.0070.01119.39
7.4.70.0150.01016.52
7.4.60.0030.01316.57
7.4.50.0110.00716.46
7.4.40.0120.01216.72
7.4.30.0150.00316.68
7.4.00.0040.00415.21
7.3.330.0000.00613.57
7.3.320.0030.00313.55
7.3.310.0030.00516.43
7.3.300.0040.00416.59
7.3.290.0020.01316.61
7.3.280.0070.01216.59
7.3.270.0070.01117.40
7.3.260.0120.00916.66
7.3.250.0140.00416.68
7.3.240.0120.00916.52
7.3.230.0120.00616.63
7.3.210.0120.01216.72
7.3.200.0100.00716.53
7.3.190.0090.00916.57
7.3.180.0120.00516.82
7.3.170.0080.00816.79
7.3.160.0060.01216.52
7.2.330.0190.00416.91
7.2.320.0100.01517.09
7.2.310.0150.00316.88
7.2.300.0120.00616.87
7.2.290.0100.01017.00
7.2.60.0070.01016.80
7.1.200.0000.01315.66
7.1.110.0070.01018.09
7.1.100.0070.01018.31
7.1.90.0030.01718.05
7.1.80.0090.00618.18
7.1.70.0030.01017.25
7.1.60.0190.01135.33
7.1.50.0110.01934.84
7.1.40.0140.01734.55
7.1.30.0230.00734.33
7.1.20.0190.01334.53
7.1.10.0100.00716.70
7.1.00.0060.00916.95
7.0.250.0030.01517.85
7.0.240.0100.01017.79
7.0.230.0060.00917.61
7.0.220.0140.00317.85
7.0.210.0030.01016.40
7.0.200.0080.00616.66
7.0.190.0030.01116.80
7.0.180.0060.00916.18
7.0.170.0060.00916.06
7.0.160.0110.00716.19
7.0.150.0080.00616.51
7.0.140.0000.01516.29
7.0.130.0080.01116.72
7.0.120.0090.00916.48
7.0.110.0090.00916.21
7.0.100.0060.01316.35
7.0.90.0070.01316.26
7.0.80.0060.00816.52
7.0.70.0080.01116.30
7.0.60.0030.01016.16
7.0.50.0070.01116.58
7.0.40.0030.01016.56
7.0.30.0060.01216.48
7.0.20.0070.00716.45
7.0.10.0070.00716.29
7.0.00.0120.00316.46

preferences:
60.94 ms | 400 KiB | 5 Q