3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Created by PhpStorm. * User: Саша * Date: 17.03.2017 * Time: 20:25 */ class Employee { public $rank = 1; public $coffee = 0; public $pages = 0; public $basicSalary = 0; public $boss = false; function __construct($rank, $boss = false) { $this->rank = $rank; $this->boss = $boss; } public function getSalary() { $rate = 0; if ($this->boss == true) { $bossRank = 1.5; } else { $bossRank = 1; } switch ($this->rank) { case 1: $rate = 1; break; case 2: $rate = 1.25; break; case 3: $rate = 1.5; break; } $rate *= $bossRank; return $this->basicSalary * $rate; } public function getCoffee() { if ($this->boss == true) { return $this->coffee * 2; } else { return $this->coffee; } } public function getPages() { if ($this->boss) { return 0; } else { return $this->pages; } } } class Manager extends Employee { public $rank = 1; public $boss = false; } class Marketer extends Employee { public $rank = 1; public $boss = false; } class Engineer extends Employee { public $rank = 1; public $boss = false; } class Analyst extends Employee { public $rank = 1; public $boss = false; } class Department { private $employees = []; private $name; function __construct($name) { $this->name = $name; } public function addEmployee($profession, $number, $rank = 1, $boss = false) { $variable = ''; for ($i = 0; $i < $number; $i++) { $variable = new $profession($rank, $boss); switch ($profession) { case 'Manager': $variable->basicSalary = 500; $variable->coffee = 20; $variable->pages = 200; break; case 'Marketer': $variable->basicSalary = 400; $variable->coffee = 15; $variable->pages = 150; break; case 'Engineer': $variable->basicSalary = 200; $variable->coffee = 5; $variable->pages = 50; break; case 'Analyst': $variable->basicSalary = 800; $variable->coffee = 50; $variable->pages = 5; break; } $this->employees[] = $variable; } } public function getName() { return $this->name; } public function getEmployeesNumber() { return count($this->employees); } public function getAllDepartmentSalary() { $result = 0; foreach ($this->employees as $employee) { $result += $employee->getSalary(); } return $result; } public function getAllDepartmentCoffee() { $result = 0; foreach ($this->employees as $employee) { $result += $employee->getCoffee(); } return $result; } public function getAllDepartmentPages() { $result = 0; foreach ($this->employees as $employee) { $result += $employee->getPages(); } return $result; } } function padRight($x, $y) { return $x . str_repeat(" ", $y - mb_strlen($x)); } function padLeft($x, $y) { return str_repeat(" ", $y - mb_strlen($x)) . $x; } function getTheValues($departments) { $col1 = 15; $col2 = 11; $countedColumns = $col1 + ($col2 * 5); $numberOfDepartments = count($departments); $allEmployees = 0; $allSalary = 0; $allCoffee = 0; $allPages = 0; $allMoneyPerPage = 0; echo padRight("Департамент", $col1) . padLeft("сотр.", $col2) . padLeft("тугр.", $col2) . padLeft("кофе", $col2) . padLeft("стр.", $col2) . padLeft("тугр./стр.", $col2) ."\n"; echo str_repeat("-", $countedColumns) ."\n"; foreach ($departments as $department) { $name = $department->getName(); $employees = $department->getEmployeesNumber(); $salary = $department->getAllDepartmentSalary(); $coffee = $department->getAllDepartmentCoffee(); $pages = $department->getAllDepartmentPages(); $moneyPerPage = round($salary / $pages, 2); echo padRight($name, $col1) . padLeft($employees, $col2) . padLeft($salary, $col2) . padLeft($coffee, $col2) . padLeft($pages, $col2) . padLeft($moneyPerPage, $col2) ."\n"; $allEmployees += $employees; $allSalary += $salary; $allCoffee += $coffee; $allPages += $pages; $allMoneyPerPage += $moneyPerPage; } echo str_repeat("-", $countedColumns) ."\n"; echo padRight("Среднее", $col1) . padLeft($allEmployees/$numberOfDepartments, $col2) . padLeft($allSalary/$numberOfDepartments, $col2) . padLeft($allCoffee/$numberOfDepartments, $col2) . padLeft($allPages/$numberOfDepartments, $col2) . padLeft($allMoneyPerPage/$numberOfDepartments, $col2) ."\n"; echo padRight("Всего", $col1) . padLeft($allEmployees, $col2) . padLeft($allSalary, $col2) . padLeft($allCoffee, $col2) . padLeft($allPages, $col2) . padLeft($allMoneyPerPage, $col2) ."\n"; } $procurementDepartment = new Department("Закупок"); $procurementDepartment->AddEmployee('Manager', 9); $procurementDepartment->AddEmployee('Manager', 3, 2); $procurementDepartment->AddEmployee('Manager', 2, 3); $procurementDepartment->AddEmployee('Marketer', 2, 1); $procurementDepartment->AddEmployee('Manager', 1, 2, true); $sellingDepartment = new Department("Продаж"); $sellingDepartment->AddEmployee('Manager', 12); $sellingDepartment->AddEmployee('Marketer', 6); $sellingDepartment->AddEmployee('Analyst', 3); $sellingDepartment->AddEmployee('Analyst', 2, 2); $sellingDepartment->AddEmployee('Manager', 1, 2, true); $advertisingDepartment = new Department("Рекламы"); $advertisingDepartment->AddEmployee('Marketer', 15); $advertisingDepartment->AddEmployee('Marketer', 10, 2); $advertisingDepartment->AddEmployee('Manager', 8); $advertisingDepartment->AddEmployee('Engineer', 2); $advertisingDepartment->AddEmployee('Manager', 1, 3, true); $logisticsDepartment = new Department("Логистики"); $logisticsDepartment->AddEmployee('Manager', 13); $logisticsDepartment->AddEmployee('Manager', 5, 2); $logisticsDepartment->AddEmployee('Engineer', 5); $logisticsDepartment->AddEmployee('Manager', 1, 1, true); $departments = [$procurementDepartment, $sellingDepartment, $advertisingDepartment, $logisticsDepartment]; getTheValues($departments);

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.0150.00416.75
8.3.50.0110.01121.33
8.3.40.0150.00419.11
8.3.30.0100.00619.13
8.3.20.0070.00020.36
8.3.10.0060.00322.15
8.3.00.0000.00821.82
8.2.180.0040.01118.25
8.2.170.0040.01122.96
8.2.160.0140.00020.55
8.2.150.0070.00324.18
8.2.140.0080.00024.66
8.2.130.0040.00422.34
8.2.120.0090.00026.35
8.2.110.0090.00020.91
8.2.100.0060.00617.84
8.2.90.0040.00419.42
8.2.80.0040.00419.28
8.2.70.0080.00017.88
8.2.60.0050.00318.29
8.2.50.0030.00518.07
8.2.40.0080.00018.24
8.2.30.0040.00418.17
8.2.20.0040.00418.36
8.2.10.0060.00318.27
8.2.00.0000.00718.39
8.1.280.0040.01125.92
8.1.270.0050.00324.04
8.1.260.0070.00026.35
8.1.250.0090.00028.09
8.1.240.0070.00423.86
8.1.230.0070.00421.16
8.1.220.0030.00618.77
8.1.210.0030.00519.22
8.1.200.0030.00717.60
8.1.190.0040.00417.48
8.1.180.0040.00418.10
8.1.170.0030.00618.77
8.1.160.0030.00519.08
8.1.150.0000.00820.50
8.1.140.0030.00519.83
8.1.130.0050.00219.12
8.1.120.0000.00817.62
8.1.110.0020.00517.61
8.1.100.0050.00317.60
8.1.90.0040.00417.63
8.1.80.0040.00417.53
8.1.70.0030.00617.63
8.1.60.0070.00317.71
8.1.50.0050.00317.73
8.1.40.0080.00017.70
8.1.30.0040.00417.91
8.1.20.0030.00617.89
8.1.10.0050.00317.83
8.1.00.0050.00317.80
8.0.300.0000.00820.15
8.0.290.0040.00416.88
8.0.280.0000.00718.75
8.0.270.0000.00717.41
8.0.260.0000.00817.53
8.0.250.0030.00317.09
8.0.240.0020.01017.23
8.0.230.0040.00417.23
8.0.220.0040.00417.09
8.0.210.0000.00717.15
8.0.200.0030.00317.27
8.0.190.0080.00017.17
8.0.180.0000.00717.05
8.0.170.0030.00617.12
8.0.160.0080.00017.03
8.0.150.0000.00817.16
8.0.140.0070.00017.14
8.0.130.0050.00213.59
8.0.120.0030.00617.09
8.0.110.0070.00017.05
8.0.100.0040.00417.03
8.0.90.0040.00417.03
8.0.80.0130.00317.12
8.0.70.0070.00017.07
8.0.60.0000.00717.00
8.0.50.0040.00417.09
8.0.30.0120.00917.32
8.0.20.0170.00917.43
8.0.10.0000.00717.16
8.0.00.0090.00917.02
7.4.330.0000.00515.55
7.4.320.0060.00016.78
7.4.300.0030.00316.66
7.4.290.0070.00016.77
7.4.280.0000.00816.75
7.4.270.0040.00416.60
7.4.260.0050.00316.75
7.4.250.0000.00716.67
7.4.240.0050.00216.58
7.4.230.0040.00416.82
7.4.220.0120.00616.79
7.4.210.0060.01016.75
7.4.200.0050.00216.81
7.4.160.0070.01016.55
7.4.150.0110.00717.40
7.4.140.0110.01017.86
7.4.130.0090.01116.70
7.4.120.0140.00716.63
7.4.110.0090.00916.63
7.4.100.0190.01916.80
7.4.90.0110.00616.75
7.4.80.0100.01419.39
7.4.70.0070.01016.76
7.4.60.0110.00716.82
7.4.50.0070.00716.52
7.4.40.0050.01116.64
7.4.30.0040.01216.46
7.4.00.0090.00815.05
7.3.330.0060.00013.38
7.3.320.0000.00513.41
7.3.310.0030.00316.58
7.3.300.0070.00016.55
7.3.290.0100.00716.50
7.3.280.0090.00916.55
7.3.270.0080.01217.40
7.3.260.0120.00716.52
7.3.250.0100.00916.52
7.3.240.0070.01216.53
7.3.230.0000.01716.50
7.3.210.0140.00416.81
7.3.200.0090.00916.85
7.3.190.0080.00816.77
7.3.180.0060.01316.68
7.3.170.0080.00816.59
7.3.160.0160.00716.48
7.3.120.0090.01115.13
7.3.110.0080.00814.95
7.3.100.0020.01515.02
7.3.90.0060.00814.78
7.3.80.0100.00514.74
7.3.70.0060.00814.99
7.3.60.0020.01315.00
7.3.50.0080.00514.81
7.3.40.0060.00814.89
7.3.30.0070.00614.92
7.3.20.0070.00616.51
7.3.10.0070.00716.77
7.3.00.0060.00816.61
7.2.330.0060.01417.00
7.2.320.0040.01416.65
7.2.310.0140.00516.96
7.2.300.0030.01516.82
7.2.290.0070.01116.80
7.2.250.0100.01015.32
7.2.240.0060.01515.17
7.2.230.0030.01215.26
7.2.220.0070.00715.12
7.2.210.0030.01215.04
7.2.200.0030.01015.27
7.2.190.0030.00915.25
7.2.180.0060.00915.15
7.2.170.0090.00715.14
7.2.60.0140.00016.83
7.1.330.0030.01215.91
7.1.320.0050.00815.76
7.1.310.0070.00515.91
7.1.300.0080.00615.82
7.1.290.0030.01015.67
7.1.280.0060.00815.82
7.1.270.0050.01015.76
7.1.260.0060.00815.91
7.1.200.0080.00415.96
7.1.70.0060.00616.95
7.1.60.0040.00817.43
7.1.30.5470.09336.65
7.1.20.4570.07336.68
7.1.10.8200.10020.53
7.1.00.5670.08320.64
7.0.200.0070.01016.49
7.0.170.5200.08720.16
7.0.160.4070.07320.01
7.0.150.7230.06320.14
7.0.140.6530.07720.21
7.0.130.3730.07320.23
7.0.120.3600.07020.18
7.0.110.3530.08720.13
7.0.100.3200.07020.17
7.0.90.2830.07020.20
7.0.80.3100.06320.15
7.0.70.4670.04720.13
7.0.60.4400.07020.04
7.0.50.3870.06320.20
7.0.40.4370.07720.22
7.0.30.4070.08320.21
7.0.20.3630.07720.14
7.0.10.4270.09020.20
7.0.00.4170.08720.12

preferences:
34.23 ms | 401 KiB | 5 Q