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; } public function padLeft($value, $columnLength){ echo $value; echo str_repeat(" ", $columnLength - mb_strlen($value)); } public function calculatiotOfOutput(array $informarion){ $col1 = 15; $col2 = 10; $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] = $totalInformation[$i] / count($this->departments); } $averageInformation[0] = "Среднее"; $this->calculatiotOfOutput($averageInformation); $this->calculatiotOfOutput($totalInformation); } } $vektor = new Company; $vektor->addDepartment(new Department("Закупок")); $vektor->addDepartment(new Department("Продаж")); //$procurementDepartment = new Department("Закупок"); // $procurementDepartment->addWorkers(new Manager(14, 1, 0)); // $procurementDepartment->addWorkers(new Manager(10, 2, 0)); //$sellingDepartment = new Department("Продаж"); // $sellingDepartment->addWorkers(new Manager(5, 1, 0)); // $vektor->addDepartment($procurementDepartment); // $vektor->addDepartment($sellingDepartment); //$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.0000.01416.88
8.3.50.0120.00316.57
8.3.40.0100.00618.73
8.3.30.0060.00918.66
8.3.20.0080.00020.29
8.3.10.0040.00423.48
8.3.00.0060.00323.56
8.2.180.0130.00616.50
8.2.170.0080.01222.96
8.2.160.0070.00720.47
8.2.150.0000.00824.18
8.2.140.0030.00524.66
8.2.130.0080.00022.11
8.2.120.0080.00026.35
8.2.110.0030.00620.36
8.2.100.0030.00917.78
8.2.90.0000.00817.89
8.2.80.0060.00319.52
8.2.70.0000.00917.63
8.2.60.0040.00417.50
8.2.50.0050.00317.68
8.2.40.0050.00519.15
8.2.30.0070.00019.33
8.2.20.0030.00518.24
8.2.10.0080.00018.22
8.2.00.0050.00218.01
8.1.280.0130.00925.92
8.1.270.0040.00423.79
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0060.00323.92
8.1.230.0090.00319.19
8.1.220.0050.00317.88
8.1.210.0000.00818.77
8.1.200.0060.00317.48
8.1.190.0040.00417.23
8.1.180.0080.00418.10
8.1.170.0030.00617.62
8.1.160.0040.00418.97
8.1.150.0050.00218.66
8.1.140.0040.00417.76
8.1.130.0040.00417.40
8.1.120.0000.00717.52
8.1.110.0040.00417.50
8.1.100.0040.00417.37
8.1.90.0050.00217.38
8.1.80.0000.00817.44
8.1.70.0040.00417.45
8.1.60.0080.00017.55
8.1.50.0000.00917.55
8.1.40.0000.00817.59
8.1.30.0000.00817.74
8.1.20.0000.00817.63
8.1.10.0040.00417.59
8.1.00.0060.00317.55
8.0.300.0030.00519.90
8.0.290.0000.00816.75
8.0.280.0000.00718.51
8.0.270.0090.00017.30
8.0.260.0000.00716.95
8.0.250.0000.00717.05
8.0.240.0040.00416.99
8.0.230.0030.00317.06
8.0.220.0040.00416.86
8.0.210.0000.00716.98
8.0.200.0070.00017.04
8.0.190.0040.00417.08
8.0.180.0110.00016.98
8.0.170.0030.00516.85
8.0.160.0000.00816.95
8.0.150.0030.00717.00
8.0.140.0000.00716.95
8.0.130.0000.00613.43
8.0.120.0040.00416.97
8.0.110.0040.00416.95
8.0.100.0040.00417.07
8.0.90.0040.00416.86
8.0.80.0040.01117.00
8.0.70.0040.00416.86
8.0.60.0030.00617.00
8.0.50.0030.00516.88
8.0.30.0120.00717.38
8.0.20.0190.00517.40
8.0.10.0040.00416.98
8.0.00.0130.00616.73
7.4.330.0000.00516.79
7.4.320.0030.00316.41
7.4.300.0030.00316.56
7.4.290.0070.00016.67
7.4.280.0000.00816.67
7.4.270.0070.00016.65
7.4.260.0000.00716.56
7.4.250.0030.00316.61
7.4.240.0040.00416.57
7.4.230.0070.00016.49
7.4.220.0170.01016.64
7.4.210.0070.00716.57
7.4.200.0070.00016.63
7.4.160.0080.01116.53
7.4.150.0070.01017.40
7.4.140.0130.00717.86
7.4.130.0100.00716.49
7.4.120.0120.00716.51
7.4.110.0080.00816.55
7.4.100.0170.00016.42
7.4.90.0130.00316.59
7.4.80.0110.00619.39
7.4.70.0000.01716.58
7.4.60.0110.00416.42
7.4.50.0080.00216.65
7.4.40.0140.00816.64
7.4.30.0130.00916.64
7.4.10.0070.01114.92
7.4.00.0070.00814.93
7.3.330.0000.00513.14
7.3.320.0000.00713.32
7.3.310.0030.00316.21
7.3.300.0030.00316.36
7.3.290.0060.00916.28
7.3.280.0100.00716.31
7.3.270.0140.00417.40
7.3.260.0100.01216.41
7.3.250.0120.00916.52
7.3.240.0090.00816.35
7.3.230.0000.01616.51
7.3.210.0110.00616.53
7.3.200.0040.01316.24
7.3.190.0110.00616.57
7.3.180.0040.01216.46
7.3.170.0090.00916.41
7.3.160.0060.01016.42
7.3.130.0030.01614.97
7.3.120.0120.00615.00
7.3.110.0030.01614.97
7.3.100.0060.00614.91
7.3.90.0040.01014.85
7.3.80.0100.00414.47
7.3.70.0050.00714.81
7.3.60.0050.00714.77
7.3.50.0070.00714.76
7.3.40.0060.00814.90
7.3.30.0000.01014.85
7.3.20.0060.00816.42
7.3.10.0080.00416.66
7.3.00.0050.01016.57
7.2.330.0030.01416.68
7.2.320.0110.00716.49
7.2.310.0110.00616.42
7.2.300.0000.01716.45
7.2.290.0120.00616.84
7.2.260.0040.01514.79
7.2.250.0000.01315.11
7.2.240.0100.00514.96
7.2.230.0060.00715.03
7.2.220.0070.00915.23
7.2.210.0050.00714.90
7.2.200.0030.00915.14
7.2.190.0000.01315.02
7.2.180.0050.01015.11
7.2.170.0060.00615.06
7.2.160.0050.00715.18
7.2.150.0090.00316.71
7.2.140.0110.00117.01
7.2.130.0090.00516.96
7.2.120.0090.00516.95
7.2.110.0030.01216.79
7.2.100.0070.00616.75
7.2.90.0090.00216.76
7.2.80.0080.00717.03
7.2.70.0060.00916.78
7.2.60.0030.00816.77
7.2.50.0050.00816.78
7.2.40.0030.01216.78
7.2.30.0060.00716.84
7.2.20.0070.00716.82
7.2.10.0120.00316.83
7.2.00.0040.00916.77
7.1.330.0050.00715.69
7.1.320.0070.00915.76
7.1.310.0080.00415.86
7.1.300.0090.00415.70
7.1.290.0060.00615.74
7.1.280.0050.00415.82
7.1.270.0040.00615.67
7.1.260.0040.00515.66
7.1.250.0080.00315.67
7.1.240.0030.01115.61
7.1.230.0040.00915.76
7.1.220.0060.01015.56
7.1.210.0050.00715.56
7.1.200.0040.01015.51
7.1.190.0040.00815.56
7.1.180.0060.00415.65
7.1.170.0050.00715.57
7.1.160.0030.00715.75
7.1.150.0020.01115.66
7.1.140.0050.00515.73
7.1.130.0030.00915.68
7.1.120.0020.01115.43
7.1.110.0070.00816.56
7.1.100.0090.00716.60
7.1.90.0070.00816.59
7.1.80.0080.00716.46
7.1.70.0070.00516.22
7.1.60.0110.00722.11
7.1.50.0110.00622.04
7.1.40.0100.01021.96
7.1.30.0070.01221.77
7.1.20.0070.01122.01
7.1.10.0020.01316.10
7.1.00.0070.00615.84
7.0.330.0020.01015.44
7.0.320.0100.00315.24
7.0.310.0060.00515.46
7.0.300.0030.00915.37
7.0.290.0060.00415.41
7.0.280.0040.00815.24
7.0.270.0050.00615.41
7.0.260.0030.01015.39
7.0.250.0090.00516.11
7.0.240.0060.01016.13
7.0.230.0090.00616.04
7.0.220.0050.00916.31
7.0.210.0020.01215.75
7.0.200.0050.00715.81
7.0.190.0060.00415.70
7.0.180.0020.01015.65
7.0.170.0060.00715.67
7.0.160.0040.00915.75
7.0.150.0050.00515.70
7.0.140.0070.00715.61
7.0.130.0030.00915.79
7.0.120.0080.00615.68
7.0.110.0030.00915.72
7.0.100.0040.00915.76
7.0.90.0090.00415.75
7.0.80.0030.01015.81
7.0.70.0050.00615.64
7.0.60.0070.00615.80
7.0.50.0060.00615.67
7.0.40.0040.00814.53
7.0.30.0030.00914.48
7.0.20.0030.00914.37
7.0.10.0010.01114.45
7.0.00.0050.00614.49
5.6.400.0040.00714.69
5.6.390.0040.00714.55
5.6.380.0030.00814.59
5.6.370.0050.00714.58
5.6.360.0090.00314.53
5.6.350.0070.00414.55
5.6.340.0080.00714.43
5.6.330.0070.00714.41
5.6.320.0050.01014.60
5.6.310.0050.00914.46
5.6.300.0070.00714.76
5.6.290.0040.01014.60
5.6.280.0050.00714.73
5.6.270.0070.00714.43
5.6.260.0070.00714.60
5.6.250.0010.00914.76
5.6.240.0010.00914.41
5.6.230.0060.00614.60
5.6.220.0040.00714.69
5.6.210.0060.00814.54
5.6.200.0080.00414.58
5.6.190.0040.00614.60
5.6.180.0080.00414.37
5.6.170.0030.00814.61
5.6.160.0070.00514.67
5.6.150.0070.00514.61
5.6.140.0030.01014.74
5.6.130.0030.00914.58
5.6.120.0080.00714.57
5.6.110.0060.00414.57
5.6.100.0080.00814.64
5.6.90.0020.00714.44
5.6.80.0040.00814.39
5.6.70.0020.01114.55
5.6.60.0050.00714.32
5.6.50.0040.00614.26
5.6.40.0050.00914.42
5.6.30.0040.00714.50
5.6.20.0030.01014.39
5.6.10.0050.00614.46
5.6.00.0020.00914.36

preferences:
54.83 ms | 401 KiB | 5 Q