3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Employee { public $baseSalary; public $rank; public $pages; public $isBoss; public $coffee; function __construct($rank, $isBoss) { $this->rank = $rank; $this->isBoss = $isBoss; $this->calculateSalary(); } private function calculateSalary() { $coef = 1; switch ($this->rank) { case 2: $coef *= 1.25; break; case 3: $coef *= 1.50; break; } $coef = ($this->isBoss ? $coef *= 1.50 : $coef); $this->salary = $this->baseSalary*$coef; } } class Manager extends Employee { public $rank = 1; public $baseSalary = 500; public $coffee = 20; public $pages = 200; public $boss = false; public $salary = 0; } class Marketer extends Employee { public $rank = 1; public $baseSalary = 400; public $coffee = 15; public $pages = 150; public $boss = false; public $salary = 0; } class Analyst extends Employee { public $rank = 1; public $baseSalary = 800; public $coffee = 50; public $pages = 5; public $boss = false; public $salary = 0; } class Engineer extends Employee { public $rank = 1; public $baseSalary = 200; public $coffee = 5; public $pages = 50; public $boss = false; public $salary = 0; } class Department { public $name; public $employees = []; function __construct($name) { $this->name = $name; } function addEmployees($position, $amountEmloyees, $rank = 1, $isBoss = false) { for ($i=0; $i < $amountEmloyees; $i++) { $this->employees[] = new $position($rank, $isBoss); } } function totalByDepartment() { $arr = ['coffeeByDept' => 0, 'pagesByDept' => 0, 'salaryByDept' => 0]; foreach ($this->employees as $key => $value) { $arr['coffeeByDept'] += $value->coffee; $arr['pagesByDept'] += $value->pages; $arr['salaryByDept'] += $value->salary; } $arr['amountEmloyees'] = count($this->employees); $arr['salaryByPage'] = round($arr['salaryByDept'] / $arr['pagesByDept'], 2); return $arr; } } $DepartmentProcurement = new Department('Procurement'); $DepartmentProcurement->addEmployees('Manager', 9); $DepartmentProcurement->addEmployees('Manager', 3, 2); $DepartmentProcurement->addEmployees('Manager', 2, 3); $DepartmentProcurement->addEmployees('Marketer', 2); $DepartmentProcurement->addEmployees('Manager', 1, 2, true); $DepartmentSales = new Department('Sales'); $DepartmentSales->addEmployees('Manager', 12); $DepartmentSales->addEmployees('Marketer', 6); $DepartmentSales->addEmployees('Analyst', 3); $DepartmentSales->addEmployees('Analyst', 2, 2); $DepartmentSales->addEmployees('Marketer', 1, 2, true); $totalBySalesDept = $DepartmentSales->totalByDepartment(); $totalByProcurementDept = $DepartmentProcurement->totalByDepartment(); var_dump($totalByProcurementDept); ?>

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.0130.00616.49
8.3.50.0090.00616.25
8.3.40.0140.00418.96
8.3.30.0110.00718.81
8.3.20.0090.00020.34
8.3.10.0070.00021.89
8.3.00.0140.00023.66
8.2.180.0120.00618.25
8.2.170.0130.00322.96
8.2.160.0040.01519.58
8.2.150.0030.00624.18
8.2.140.0020.00524.66
8.2.130.0040.00426.16
8.2.120.0050.00320.88
8.2.110.0000.01022.25
8.2.100.0060.00617.84
8.2.90.0000.00817.75
8.2.80.0050.00518.91
8.2.70.0000.00817.63
8.2.60.0000.00918.05
8.2.50.0050.00318.07
8.2.40.0050.00318.29
8.2.30.0000.00818.38
8.2.20.0080.00018.33
8.2.10.0040.00418.34
8.2.00.0000.00818.50
8.1.280.0090.00925.92
8.1.270.0000.00823.82
8.1.260.0060.00326.35
8.1.250.0080.00028.09
8.1.240.0000.01019.46
8.1.230.0040.00821.16
8.1.220.0030.00517.91
8.1.210.0000.00918.77
8.1.200.0030.00717.60
8.1.190.0000.00817.48
8.1.180.0060.00318.10
8.1.170.0000.00818.64
8.1.160.0040.00418.99
8.1.150.0070.00020.39
8.1.140.0000.00719.75
8.1.130.0070.00019.14
8.1.120.0050.00317.55
8.1.110.0040.00417.59
8.1.100.0030.00617.54
8.1.90.0030.00417.56
8.1.80.0050.00217.57
8.1.70.0000.00717.52
8.1.60.0040.00417.72
8.1.50.0020.00517.55
8.1.40.0050.00317.67
8.1.30.0080.00017.74
8.1.20.0050.00317.81
8.1.10.0020.00517.57
8.1.00.0030.00517.65
8.0.300.0060.00318.77
8.0.290.0040.00416.88
8.0.280.0000.00718.48
8.0.270.0030.00317.43
8.0.260.0030.00617.32
8.0.250.0040.00517.01
8.0.240.0030.00717.07
8.0.230.0040.00417.13
8.0.220.0030.00317.01
8.0.210.0030.00317.03
8.0.200.0070.00017.08
8.0.190.0040.00416.95
8.0.180.0080.00017.06
8.0.170.0050.00217.10
8.0.160.0030.00617.07
8.0.150.0030.00916.95
8.0.140.0030.00517.02
8.0.130.0000.00613.42
8.0.120.0030.00616.96
8.0.110.0040.00417.05
8.0.100.0040.00416.96
8.0.90.0050.00316.99
8.0.80.0130.00317.06
8.0.70.0040.00416.89
8.0.60.0000.00817.08
8.0.50.0040.00416.93
8.0.30.0080.01417.16
8.0.20.0160.01017.43
8.0.10.0050.00317.09
8.0.00.0090.01116.71
7.4.330.0000.00615.55
7.4.320.0000.00616.63
7.4.300.0060.00016.70
7.4.290.0070.00416.71
7.4.280.0050.00316.62
7.4.270.0070.00016.64
7.4.260.0050.00516.48
7.4.250.0050.00316.74
7.4.240.0040.00416.63
7.4.230.0070.00016.84
7.4.220.0090.01816.65
7.4.210.0070.00716.52
7.4.200.0030.00516.63
7.4.160.0070.00916.80
7.4.150.0070.01117.40
7.4.140.0110.01117.86
7.4.130.0100.01016.70
7.4.120.0100.01016.56
7.4.110.0150.00916.51
7.4.100.0140.00316.62
7.4.90.0060.01116.45
7.4.80.0090.00919.39
7.4.70.0050.01416.70
7.4.60.0120.00616.66
7.4.50.0000.01916.72
7.4.40.0060.01116.73
7.4.30.0150.00616.68
7.4.00.0000.01414.77
7.3.330.0080.00013.41
7.3.320.0000.00513.46
7.3.310.0000.00816.59
7.3.300.0070.00016.48
7.3.290.0050.01016.45
7.3.280.0080.01016.45
7.3.270.0120.01217.40
7.3.260.0060.01316.73
7.3.250.0090.00716.55
7.3.240.0130.00616.64
7.3.230.0110.00816.40
7.3.210.0060.01216.71
7.3.200.0060.01016.65
7.3.190.0110.01016.67
7.3.180.0070.01016.54
7.3.170.0090.00916.64
7.3.160.0090.00716.42
7.3.120.0120.00614.95
7.3.110.0060.00915.04
7.3.100.0070.00714.77
7.3.90.0060.01014.68
7.3.80.0090.00914.64
7.3.70.0060.00614.66
7.3.60.0030.01315.01
7.3.50.0060.00914.97
7.3.40.0100.00314.88
7.3.30.0030.01414.74
7.3.20.0040.01116.77
7.3.10.0070.01016.58
7.3.00.0060.00616.80
7.2.330.0090.00916.70
7.2.320.0090.00916.77
7.2.310.0100.00716.85
7.2.300.0100.01616.59
7.2.290.0040.01416.96
7.2.240.0070.01015.27
7.2.230.0100.00715.29
7.2.220.0030.01315.21
7.2.210.0080.00414.70
7.2.200.0060.01315.00
7.2.190.0080.00315.21
7.2.180.0030.00715.07
7.2.170.0080.00614.86
7.2.160.0060.00915.12
7.2.150.0060.01017.02
7.2.140.0090.00616.77
7.2.130.0030.01317.01
7.2.120.0080.00816.85
7.2.110.0090.00616.72
7.2.100.0030.01316.88
7.2.90.0120.00317.10
7.2.80.0110.00716.84
7.2.70.0100.00317.21
7.2.60.0070.00916.91
7.2.50.0070.00517.00
7.2.40.0070.00717.11
7.2.30.0070.01017.05
7.2.20.0060.00916.99
7.2.10.0070.01017.14
7.2.00.0030.01016.89
7.1.330.0040.01115.84
7.1.320.0000.01815.66
7.1.310.0000.01615.96
7.1.300.0060.00915.64
7.1.290.0000.01315.80
7.1.280.0100.00715.84
7.1.270.0000.01515.59
7.1.260.0090.00615.77
7.1.250.0080.00415.90
7.1.200.0030.00915.96
7.1.70.0100.00017.08
7.1.60.0060.00617.12
7.1.30.0670.06336.36
7.1.20.0570.05336.54
7.1.10.0530.07020.40
7.1.00.0600.06320.61
7.0.200.0030.01316.80
7.0.170.0800.08720.04
7.0.160.0700.07320.05
7.0.150.1770.05320.07
7.0.140.0530.05320.10
7.0.130.0330.06320.20
7.0.120.0430.05320.06
7.0.110.0330.06720.13
7.0.100.0930.08020.09
7.0.90.0670.06320.03
7.0.80.0700.07720.13
7.0.70.0730.06720.03
7.0.60.0470.07720.21
7.0.50.0970.05020.15
7.0.40.0470.06020.17
7.0.30.0430.06020.08
7.0.20.0730.05320.11
7.0.10.0670.05320.12
7.0.00.0670.06020.02

preferences:
59.11 ms | 400 KiB | 5 Q