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 $basicSalary = 500; public $coffee = 20; public $pages = 200; public $boss = false; } class Marketer extends Employee { public $rank = 1; public $basicSalary = 400; public $coffee = 15; public $pages = 150; public $boss = false; } class Engineer extends Employee { public $rank = 1; public $basicSalary = 200; public $coffee = 5; public $pages = 50; public $boss = false; } class Analyst extends Employee { public $rank = 1; public $basicSalary = 800; public $coffee = 50; public $pages = 5; public $boss = false; } class Department { private $employees = []; private $name; function __construct($name) { $this->name = $name; } public function addEmployee($profession, $number, $rank = 1, $boss = false) { for ($i = 0; $i < $number; $i++) { $this->employees[] = new $profession($rank, $boss); } } 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 $key => $value) { $name = $departments[$key]->getName(); $employees = $departments[$key]->getEmployeesNumber(); $salary = $departments[$key]->getAllDepartmentSalary(); $coffee = $departments[$key]->getAllDepartmentCoffee(); $pages = $departments[$key]->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.4.120.0120.01018.54
8.4.110.0140.00818.73
8.4.100.0100.00717.88
8.4.90.0110.00922.50
8.4.80.0110.00919.00
8.4.70.0090.01018.81
8.4.60.0090.00420.46
8.4.50.0110.00624.30
8.4.40.0160.00319.25
8.4.30.0200.00720.63
8.4.20.0070.01417.49
8.4.10.0060.00319.64
8.3.250.0110.00518.36
8.3.240.0030.00616.78
8.3.230.0110.00816.77
8.3.220.0040.00518.88
8.3.210.0050.00416.64
8.3.200.0040.00516.81
8.3.190.0120.00818.05
8.3.180.0090.00916.73
8.3.170.0080.00016.82
8.3.160.0120.00616.48
8.3.150.0140.00717.55
8.3.140.0090.00616.73
8.3.130.0050.00318.29
8.3.120.0030.00620.86
8.3.110.0050.00520.94
8.3.100.0030.00616.75
8.3.90.0040.00416.49
8.3.80.0100.00317.97
8.3.70.0100.01018.43
8.3.60.0190.00016.75
8.3.50.0300.00722.16
8.3.40.0120.00318.77
8.3.30.0150.00018.79
8.3.20.0000.00820.45
8.3.10.0000.00820.41
8.3.00.0000.00823.67
8.2.290.0140.00517.01
8.2.280.0040.00418.32
8.2.270.0040.01216.79
8.2.260.0060.00320.82
8.2.250.0080.01217.01
8.2.240.0150.00418.84
8.2.230.0000.00922.58
8.2.220.0100.00024.06
8.2.210.0080.00826.77
8.2.200.0030.00616.50
8.2.190.0040.01116.63
8.2.180.0140.00718.12
8.2.170.0120.00322.96
8.2.160.0140.00020.64
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0050.00326.16
8.2.120.0080.00020.79
8.2.110.0050.00520.77
8.2.100.0060.00918.09
8.2.90.0040.00418.16
8.2.80.0000.00819.54
8.2.70.0080.00018.05
8.2.60.0060.00318.28
8.2.50.0030.00518.15
8.2.40.0050.00320.71
8.2.30.0060.00320.63
8.2.20.0060.00318.30
8.2.10.0050.00318.29
8.2.00.0030.00518.37
8.1.330.0140.00716.07
8.1.320.0130.00716.20
8.1.310.0070.01116.81
8.1.300.0080.00016.31
8.1.290.0040.00818.88
8.1.280.0190.00325.92
8.1.270.0070.00722.30
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0070.00323.98
8.1.230.0090.00322.21
8.1.220.0050.00517.78
8.1.210.0040.00418.77
8.1.200.0050.00517.61
8.1.190.0030.00717.48
8.1.180.0000.00818.10
8.1.170.0000.00918.84
8.1.160.0000.00819.12
8.1.150.0040.00420.33
8.1.140.0060.00319.73
8.1.130.0080.00017.67
8.1.120.0000.00717.70
8.1.110.0050.00517.57
8.1.100.0040.00417.61
8.1.90.0040.00417.64
8.1.80.0050.00517.51
8.1.70.0030.00517.65
8.1.60.0060.00317.72
8.1.50.0060.00317.83
8.1.40.0030.00617.71
8.1.30.0040.00417.91
8.1.20.0040.00417.88
8.1.10.0070.00317.79
8.1.00.0040.00717.64
8.0.300.0030.00519.74
8.0.290.0080.00017.00
8.0.280.0000.00718.69
8.0.270.0070.00017.56
8.0.260.0070.00016.95
8.0.250.0040.00417.28
8.0.240.0000.00917.24
8.0.230.0050.00217.22
8.0.220.0000.00817.13
8.0.210.0070.00017.18
8.0.200.0030.00317.20
8.0.190.0040.00417.17
8.0.180.0000.00817.06
8.0.170.0000.00717.00
8.0.160.0030.00517.25
8.0.150.0000.00817.00
8.0.140.0030.00517.02
8.0.130.0000.00613.52
8.0.120.0080.00017.12
8.0.110.0000.00816.92
8.0.100.0000.00717.15
8.0.90.0030.00616.96
8.0.80.0100.01017.11
8.0.70.0040.00416.97
8.0.60.0000.00717.16
8.0.50.0000.00717.14
8.0.30.0130.00717.18
8.0.20.0110.01017.45
8.0.10.0020.00517.19
8.0.00.0130.01316.82
7.4.330.0030.00315.55
7.4.320.0020.00516.78
7.4.300.0000.00616.59
7.4.290.0080.00016.80
7.4.280.0000.00816.71
7.4.270.0000.00816.77
7.4.260.0000.00916.69
7.4.250.0020.00516.79
7.4.240.0000.00716.59
7.4.230.0000.00716.69
7.4.220.0110.01416.75
7.4.210.0090.00616.77
7.4.200.0000.00716.88
7.4.160.0100.00616.74
7.4.150.0060.01517.40
7.4.140.0090.01417.86
7.4.130.0110.01016.71
7.4.120.0120.00716.76
7.4.110.0100.00716.64
7.4.100.0120.00616.86
7.4.90.0150.00316.71
7.4.80.0040.01819.39
7.4.70.0170.00316.64
7.4.60.0110.00616.55
7.4.50.0060.00916.56
7.4.40.0060.01216.61
7.4.30.0170.00716.71
7.4.10.0060.01215.29
7.4.00.0080.01015.05
7.3.330.0030.00613.41
7.3.320.0030.00313.53
7.3.310.0050.00216.58
7.3.300.0000.00716.41
7.3.290.0080.00816.56
7.3.280.0090.01016.57
7.3.270.0040.01317.40
7.3.260.0100.00816.68
7.3.250.0120.00616.65
7.3.240.0080.01316.50
7.3.230.0070.01016.82
7.3.210.0060.01216.56
7.3.200.0090.01216.62
7.3.190.0150.00716.80
7.3.180.0050.01216.70
7.3.170.0060.01416.72
7.3.160.0030.01316.61
7.3.130.0100.01014.87
7.3.120.0020.01715.05
7.3.110.0090.01014.95
7.3.100.0030.01015.11
7.3.90.0020.01015.10
7.3.80.0100.00315.07
7.3.70.0040.01114.80
7.3.60.0100.00514.88
7.3.50.0020.00914.90
7.3.40.0060.00814.92
7.3.30.0030.00915.00
7.3.20.0060.00616.64
7.3.10.0070.01116.52
7.3.00.0090.00516.68
7.2.330.0090.01116.79
7.2.320.0090.01117.09
7.2.310.0090.00916.85
7.2.300.0100.00917.02
7.2.290.0120.00817.00
7.2.260.0130.00715.45
7.2.250.0100.01015.35
7.2.240.0070.00815.16
7.2.230.0070.00514.89
7.2.220.0120.00515.27
7.2.210.0050.00715.08
7.2.200.0080.00815.28
7.2.190.0050.00915.27
7.2.180.0050.00515.21
7.2.170.0080.00615.36
7.2.160.0060.00915.25
7.2.150.0150.00316.80
7.2.140.0060.00917.22
7.2.130.0100.00816.97
7.2.120.0080.01016.78
7.2.110.0160.00916.91
7.2.100.0060.01316.99
7.2.90.0210.00716.77
7.2.80.0240.00616.78
7.2.70.0080.01016.94
7.2.60.0080.00816.92
7.2.50.0130.00917.04
7.2.40.0100.00816.68
7.2.30.0170.01016.97
7.2.20.0170.00716.95
7.2.10.0110.00716.77
7.2.00.0110.00816.74
7.1.330.0040.01115.90
7.1.320.0030.00615.87
7.1.310.0050.01015.84
7.1.300.0090.00615.84
7.1.290.0050.00815.81
7.1.280.0070.00615.84
7.1.270.0080.00815.78
7.1.260.0090.00815.74
7.1.250.0070.00715.77
7.1.240.0060.00915.79
7.1.230.0030.01015.85
7.1.220.0050.00515.79
7.1.210.0140.00015.55
7.1.200.0050.00815.88
7.1.190.0000.01615.57
7.1.180.0040.01115.64
7.1.170.0040.01115.55
7.1.160.0030.00715.88
7.1.150.0000.01615.82
7.1.140.0070.00615.77
7.1.130.0030.01015.97
7.1.120.0030.01315.89
7.1.110.0000.01115.97
7.1.100.0040.00815.65
7.1.90.0060.00615.86
7.1.80.0070.01015.82
7.1.70.0040.00516.53
7.1.60.0050.00816.64
7.1.50.0060.01215.61
7.1.40.0110.00716.04
7.1.30.0550.03526.35
7.1.20.0550.03726.24
7.1.10.0620.03818.22
7.1.00.0640.03918.22
7.0.330.0120.00315.61
7.0.320.0040.00415.40
7.0.310.0040.00715.43
7.0.300.0030.00615.44
7.0.290.0060.00615.45
7.0.280.0070.01015.37
7.0.270.0000.01415.30
7.0.260.0060.00615.57
7.0.250.0030.01215.52
7.0.240.0040.00815.40
7.0.230.0070.00715.41
7.0.220.0040.00715.42
7.0.210.0100.00715.47
7.0.200.0030.01215.95
7.0.190.0040.01415.45
7.0.180.0110.00715.37
7.0.170.0430.02717.88
7.0.160.0650.03417.97
7.0.150.0580.03517.87
7.0.140.0560.04117.84
7.0.130.0590.04517.69
7.0.120.0600.03717.82
7.0.110.0620.03517.90
7.0.100.0480.03417.93
7.0.90.0650.03017.78
7.0.80.0350.03617.88
7.0.70.0650.03317.88
7.0.60.0600.04017.72
7.0.50.1100.04417.95
7.0.40.0460.03016.92
7.0.30.0460.03616.96
7.0.20.0670.04316.76
7.0.10.0550.03316.82
7.0.00.0480.03116.89
5.6.400.0030.01014.84
5.6.390.0090.00914.67
5.6.380.0130.00014.73
5.6.370.0040.01114.70
5.6.360.0030.01014.55
5.6.350.0000.01314.76
5.6.340.0070.01014.59
5.6.330.0070.00714.84
5.6.320.0070.00714.49
5.6.310.0120.00614.80
5.6.300.0030.01514.83
5.6.290.0060.00314.55
5.6.280.0070.00714.53
5.6.270.0090.00014.48
5.6.260.0030.00614.32
5.6.250.0030.01714.52
5.6.240.0070.00714.59
5.6.230.0030.01414.62
5.6.220.0070.00714.56
5.6.210.0030.00614.61
5.6.200.0070.01014.76
5.6.190.0060.01314.37
5.6.180.0060.00914.37
5.6.170.0090.00614.56
5.6.160.0070.00714.68
5.6.150.0060.00914.48
5.6.140.0090.00614.68
5.6.130.0060.00914.18
5.6.120.0070.00714.61
5.6.110.0040.01114.49
5.6.100.0100.00614.72
5.6.90.0070.00714.77
5.6.80.0040.00714.59
5.6.70.0000.00914.46
5.6.60.0000.01014.68
5.6.50.0030.01014.56
5.6.40.0120.00314.56
5.6.30.0030.00714.32
5.6.20.0060.00614.51
5.6.10.0030.01214.59
5.6.00.0100.00314.36

preferences:
28.62 ms | 403 KiB | 5 Q