3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); abstract class AbstractWorker{ public $rank; public $isBoss; public $count; public $coffeeConsumption; public $salary; public $printedPages; public function __construct($count, $rank, $isBoss) { $this->rank = $rank; $this->count = $count; $this->isBoss = $isBoss; } 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->coffeeConsumption = $this->coffeeConsumption * $this->count; $this->printedPages = $this->printedPages * $this->count; if ($this->isBoss == 1){ $this->salary *= 1.5; $this->coffeeConsumption *= 2; $this->printedPages = 0; } } public function print($value){ return $value; } } class Manager extends AbstractWorker{ public $coffeeConsumption = 20; public $salary = 500; public $printedPages = 200; } class Marketer extends AbstractWorker{ public $coffeeConsumption = 15; public $salary = 400; public $printedPages = 150; } class Engineer extends AbstractWorker{ public $coffeeConsumption = 5; public $salary = 200; public $printedPages = 50; } class Analyst extends AbstractWorker{ public $coffeeConsumption = 50; public $salary = 800; public $printedPages = 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 getInformation(){ $information = array( "name" => 0, "count" => 0, "coffee" => 0, "salary" => 0, "pages" => 0, "salaryDivedePagas" => 0 ); foreach ($this->workers as $worker) { $information["count"] += $worker->print($worker->count); $information["coffee"] += $worker->print($worker->coffeeConsumption); $information["salary"] += $worker->print($worker->salary); $information["pages"] += $worker->print($worker->printedPages); } $information["name"] = $this->name; $information["salaryDividePages"] = $information["salary"] / $information["pages"]; return $information; } } class Company { public $departments = array(); public $col = array(30, 8, 30, 8, 8, 15); public function addDepartment(Department $name){ $this->departments[] = $name; } public function padRight($string, $length){ echo $string; echo str_repeat(" ", $length - mb_strlen($string)); } public function printString(array $array, array $col){ echo $this->padRight($array[0], $this->col[0]) . $this->padRight($array[1], $this->col[1]) . $this->padRight($array[2], $this->col[2]). $this->padRight($array[3], $this->col[3]) . $this->padRight($array[4], $this->col[4]) . $this->padRight($array[5], $this->col[5]); echo "\n\n"; } public function printColumnName(){ $columnName = array("Департамент", "сотр.", "тург", "кофе", "cтр.", "тугр./стр."); // echo $this->padRight("Департамент", $this->col[0]) . // $this->padRight("сотр.", $this->col[1]) . // $this->padRight("тург.", $this->col[2]). // $this->padRight("кофе", $this->col[3]) . // $this->padRight("стр.", $this->col[4]) . // $this->padRight("тугр./стр.", $this->col[5]); // echo "\n\n"; printString($columnName, $this->col); } public function printDepartment(){ foreach ($this->departments as $department) { $information = $department->getInformation(); echo $this->padRight($information["name"], $this->col[0]). $this->padRight($information["count"], $this->col[1]). $this->padRight($information["coffee"], $this->col[2]). $this->padRight($information["salary"], $this->col[3]). $this->padRight($information["pages"], $this->col[4]). $this->padRight($information["salaryDividePages"], $this->col[5]); echo "\n"; } echo "\n"; } public function printTotalValue(){ $totalCoffee = 0; $totalWorkers = 0; $totalSalary = 0; $totalPages = 0; $totalSalaryDivedePages = 0; $totalValue = array(); foreach ($this->departments as $department) { $totalValues = $department->getInformation(); $totalCoffee += $totalValues["coffee"]; $totalWorkers += $totalValues["count"]; $totalSalary += $totalValues["salary"]; $totalPages += $totalValues["pages"]; $totalSalaryDivedePages += $totalValues["salaryDividePages"]; } echo $this->padRight("Всего", $this->col[0]). $this->padRight($totalWorkers, $this->col[1]). $this->padRight($totalSalary, $this->col[2]). $this->padRight($totalCoffee, $this->col[3]). $this->padRight($totalPages, $this->col[4]). $this->padRight($totalSalaryDivedePages, $this->col[5]); echo "\n"; } public function printAverageValue(){ $averageCoffee = 0; $averageWorkers = 0; $averageSalary = 0; $averagePages = 0; $averageSalaryDivedePages = 0; $averageValue = array(); foreach ($this->departments as $department) { $averageValues = $department->getInformation(); $averageCoffee += $averageValues["coffee"]; $averageWorkers += $averageValues["count"]; $averageSalary += $averageValues["salary"]; $averagePages += $averageValues["pages"]; $averageSalaryDivedePages += $averageValues["salaryDividePages"]; } $averageCoffee /= count($this->departments); $averageSalary /= count($this->departments); $averageWorkers /= count($this->departments); $averagePages /= count($this->departments); $averageSalaryDivedePages /= count($this->departments); echo $this->padRight("Среднее", $this->col[0]). $this->padRight($averageWorkers, $this->col[1]). $this->padRight($averageSalary, $this->col[2]). $this->padRight($averageCoffee, $this->col[3]). $this->padRight($averagePages, $this->col[4]). $this->padRight($averageSalaryDivedePages, $this->col[5]); } } $vektor = new Company; $procurementDepartment = new Department("Закупок"); $procurementDepartment->addWorkers(new Manager(9, 1, 0)); $procurementDepartment->addWorkers(new Manager(3, 2, 0)); $procurementDepartment->addWorkers(new Manager(2, 3, 0)); $procurementDepartment->addWorkers(new Marketer(2, 1, 0)); $procurementDepartment->addWorkers(new Manager(1, 2, 1)); $sellingDepartment = new Department("Продаж"); $sellingDepartment->addWorkers(new Manager(12, 1, 0)); $sellingDepartment->addWorkers(new Marketer(6, 1, 0)); $sellingDepartment->addWorkers(new Analyst(3, 1, 0)); $sellingDepartment->addWorkers(new Analyst(2, 2, 0)); $sellingDepartment->addWorkers(new Marketer(1, 2, 1)); $advertisingDepartment = new Department("Рекламы"); $advertisingDepartment->addWorkers(new Marketer(15, 1, 0)); $advertisingDepartment->addWorkers(new Marketer(10, 2, 0)); $advertisingDepartment->addWorkers(new Manager(8, 1, 0)); $advertisingDepartment->addWorkers(new Engineer(2, 1, 0)); $advertisingDepartment->addWorkers(new Marketer(1, 3, 1)); $logisticsDepartment = new Department("Логистики"); $logisticsDepartment->addWorkers(new Manager(13, 1, 0)); $logisticsDepartment->addWorkers(new Manager(5, 2, 0)); $logisticsDepartment->addWorkers(new Engineer(5, 1, 0)); $logisticsDepartment->addWorkers(new Manager(1, 1, 1)); $vektor->addDepartment($procurementDepartment); $vektor->addDepartment($sellingDepartment); $vektor->addDepartment($advertisingDepartment); $vektor->addDepartment($logisticsDepartment); $vektor->printColumnName(); $vektor->printDepartment(); $vektor->printTotalValue(); $vektor->printAverageValue();

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.0070.01317.00
8.3.50.0080.01116.42
8.3.40.0110.00718.96
8.3.30.0110.00719.11
8.3.20.0040.00420.46
8.3.10.0070.00023.65
8.3.00.0080.00023.64
8.2.180.0060.01216.88
8.2.170.0130.00322.96
8.2.160.0040.01120.57
8.2.150.0000.00824.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0000.01019.58
8.2.110.0030.00619.52
8.2.100.0090.00317.97
8.2.90.0000.00817.88
8.2.80.0000.00818.98
8.2.70.0080.00317.75
8.2.60.0050.00317.88
8.2.50.0040.00417.88
8.2.40.0050.00318.00
8.2.30.0040.00419.47
8.2.20.0080.00018.25
8.2.10.0040.00418.30
8.2.00.0040.00418.17
8.1.280.0070.01125.92
8.1.270.0060.00324.02
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0090.00020.94
8.1.230.0080.00320.97
8.1.220.0030.00618.67
8.1.210.0050.00318.99
8.1.200.0030.00517.48
8.1.190.0050.00317.47
8.1.180.0030.00618.10
8.1.170.0050.00317.64
8.1.160.0040.00418.98
8.1.150.0000.00819.07
8.1.140.0030.00519.72
8.1.130.0040.00419.11
8.1.120.0050.00217.65
8.1.110.0050.00317.63
8.1.100.0070.00317.62
8.1.90.0070.00317.51
8.1.80.0040.00417.64
8.1.70.0030.00617.62
8.1.60.0070.00717.72
8.1.50.0030.00517.72
8.1.40.0040.00417.69
8.1.30.0000.00917.82
8.1.20.0040.00417.82
8.1.10.0030.00517.76
8.1.00.0030.00517.61
8.0.300.0000.00720.29
8.0.290.0030.00616.87
8.0.280.0000.00818.54
8.0.270.0000.00817.34
8.0.260.0040.00417.05
8.0.250.0030.00517.11
8.0.240.0030.00617.27
8.0.230.0050.00317.18
8.0.220.0000.00716.95
8.0.210.0030.00517.06
8.0.200.0030.00316.96
8.0.190.0050.00317.07
8.0.180.0080.00016.99
8.0.170.0000.00817.07
8.0.160.0000.00716.99
8.0.150.0040.00417.07
8.0.140.0060.00316.87
8.0.130.0030.00313.50
8.0.120.0040.00417.00
8.0.110.0030.00617.03
8.0.100.0000.00816.95
8.0.90.0000.00816.96
8.0.80.0070.01017.19
8.0.70.0080.00017.24
8.0.60.0000.00817.02
8.0.50.0040.00416.94
8.0.30.0060.01117.42
8.0.20.0110.00917.43
8.0.10.0050.00317.32
8.0.00.0060.01716.87
7.4.330.0070.00015.55
7.4.320.0000.00616.80
7.4.300.0030.00316.67
7.4.290.0040.00416.66
7.4.280.0040.00416.64
7.4.270.0050.00216.70
7.4.260.0060.00316.65
7.4.250.0050.00316.57
7.4.240.0040.00416.76
7.4.230.0040.00416.68
7.4.220.0150.01516.62
7.4.210.0090.00816.70
7.4.200.0000.00816.80
7.4.160.0070.00916.67
7.4.150.0170.00317.40
7.4.140.0090.01217.86
7.4.130.0090.00916.67
7.4.120.0080.01116.76
7.4.110.0070.01016.65
7.4.100.0110.01116.84
7.4.90.0110.00816.69
7.4.80.0100.01419.39
7.4.70.0060.01216.60
7.4.60.0030.01316.71
7.4.50.0080.01116.75
7.4.40.0030.01416.67
7.4.30.0130.00316.59
7.4.10.0100.01015.29
7.4.00.0060.00815.23
7.3.330.0000.00613.58
7.3.320.0030.00313.57
7.3.310.0000.00716.46
7.3.300.0030.00616.43
7.3.290.0000.00716.46
7.3.280.0090.00916.57
7.3.270.0070.01317.40
7.3.260.0130.00516.71
7.3.250.0120.01016.72
7.3.240.0070.01116.61
7.3.230.0070.01016.57
7.3.210.0160.00916.71
7.3.200.0090.00916.62
7.3.190.0030.01716.84
7.3.180.0100.00716.75
7.3.170.0080.00816.61
7.3.160.0000.01616.80
7.3.130.0070.01115.25
7.3.120.0060.01214.77
7.3.110.0160.00315.04
7.3.100.0030.01014.91
7.3.90.0100.00714.99
7.3.80.0000.00814.99
7.3.70.0100.00715.02
7.3.60.0030.01014.98
7.3.50.0060.00915.16
7.3.40.0000.01115.17
7.3.30.0130.00314.85
7.3.20.0060.00616.84
7.3.10.0070.01016.75
7.3.00.0110.00316.59
7.2.330.0040.01416.82
7.2.320.0130.00616.59
7.2.310.0070.01316.83
7.2.300.0140.01016.83
7.2.290.0160.00216.92
7.2.260.0000.01715.20
7.2.250.0070.01414.83
7.2.240.0090.00315.42
7.2.230.0040.01215.26
7.2.220.0080.00815.41
7.2.210.0100.01015.32
7.2.200.0030.00615.18
7.2.190.0040.01115.36
7.2.180.0040.00815.03
7.2.170.0060.01015.10
7.2.160.0060.00614.92
7.2.150.0040.01516.93
7.2.140.0100.00616.93
7.2.130.0060.00616.91
7.2.120.0000.01316.93
7.2.110.0000.01516.99
7.2.100.0060.01216.59
7.2.90.0030.01016.68
7.2.80.0150.00317.03
7.2.70.0030.01016.72
7.2.60.0070.00716.97
7.2.50.0070.00716.97
7.2.40.0080.00816.77
7.2.30.0070.00716.78
7.2.20.0100.00617.08
7.2.10.0030.00917.07
7.2.00.0030.00716.98
7.1.330.0070.00715.82
7.1.320.0040.00816.04
7.1.310.0090.00315.51
7.1.300.0030.00915.81
7.1.290.0000.00815.87
7.1.280.0100.00615.68
7.1.270.0000.01515.75
7.1.260.0030.01015.91
7.1.250.0070.00715.80
7.1.240.0060.01215.84
7.1.230.0030.00715.89
7.1.220.0060.00915.46
7.1.210.0080.00315.80
7.1.200.0050.00915.66
7.1.190.0060.00615.64
7.1.180.0030.00915.83
7.1.170.0000.00815.79
7.1.160.0130.00015.97
7.1.150.0060.00615.78
7.1.140.0070.00715.77
7.1.130.0060.00615.62
7.1.120.0070.00415.52
7.1.110.0080.00816.12
7.1.100.0090.00916.14
7.1.90.0120.00415.88
7.1.80.0070.01116.05
7.1.70.0110.00815.54
7.1.60.0100.01324.60
7.1.50.0150.00724.63
7.1.40.0160.00624.23
7.1.30.0120.01224.34
7.1.20.0100.01424.44
7.1.10.0050.01015.46
7.1.00.0060.01015.51
7.0.330.0080.00515.47
7.0.320.0030.00715.22
7.0.310.0060.00815.49
7.0.300.0100.00315.54
7.0.290.0090.00315.22
7.0.280.0000.00915.47
7.0.270.0070.00315.43
7.0.260.0060.00615.48
7.0.250.0070.01215.88
7.0.240.0060.00715.70
7.0.230.0120.00215.89
7.0.220.0160.00515.71
7.0.210.0050.01315.29
7.0.200.0080.00815.34
7.0.190.0090.00515.13
7.0.180.0100.00814.91
7.0.170.0070.01315.07
7.0.160.0090.00814.98
7.0.150.0090.00714.94
7.0.140.0090.00515.16
7.0.130.0070.00715.08
7.0.120.0090.00715.06
7.0.110.0080.00815.10
7.0.100.0110.01015.02
7.0.90.0090.00615.03
7.0.80.0160.00715.08
7.0.70.0040.00915.19
7.0.60.0070.00914.86
7.0.50.0040.01015.08
7.0.40.0050.01014.20
7.0.30.0100.00514.08
7.0.20.0110.00714.11
7.0.10.0060.00814.29
7.0.00.0080.00914.04
5.6.400.0120.00314.35
5.6.390.0090.00614.13
5.6.380.0040.00414.15
5.6.370.0070.00413.99
5.6.360.0090.00613.89
5.6.350.0030.00814.29
5.6.340.0030.01414.12
5.6.330.0080.00314.33
5.6.320.0040.01414.50
5.6.310.0080.00814.34
5.6.300.0000.01113.80
5.6.290.0040.00814.15
5.6.280.0040.00813.88
5.6.270.0000.00914.09
5.6.260.0070.00714.07
5.6.250.0120.00314.09
5.6.240.0030.01014.08
5.6.230.0080.00414.24
5.6.220.0060.00813.90
5.6.210.0070.00714.02
5.6.200.0100.00314.23
5.6.190.0030.00614.13
5.6.180.0100.00313.85
5.6.170.0030.01214.20
5.6.160.0130.00314.21
5.6.150.0040.00814.34
5.6.140.0140.00014.32
5.6.130.0040.01414.19
5.6.120.0100.00714.18
5.6.110.0060.00613.96
5.6.100.0030.01013.89
5.6.90.0040.01113.95
5.6.80.0000.01414.04
5.6.70.0000.01113.85
5.6.60.0060.01014.01
5.6.50.0090.00913.88
5.6.40.0030.01313.79
5.6.30.0060.01213.94
5.6.20.0060.01314.09
5.6.10.0110.00713.98
5.6.00.0070.01314.15

preferences:
61.99 ms | 401 KiB | 5 Q