3v4l.org

run code in 300+ PHP versions simultaneously
<?php // класс для хранения данных о сотруднике class Employee { private $_name; private $_departament; public function __construct($name, $departament) { $this->_name = $name; $this->_departament = $departament; } public function getName() { return $this->_name; } public function getDepartament() { return $this->_departament; } } // класс для хранения списка объектов class ObjectList { private $_objList; public function __construct() { $this->free(); } /** *чтобы не скучать! */ public function free() { $this->_objList = array(); } public function count() { return count($this->_objList); } public function add($obj) { array_push($this->_objList, $obj); } public function remove($obj) { $k = array_search( $obj, $this->_objList, true ); if ( $k !== false ) { unset( $this->_objList[$k] ); } } public function get($index) { return $this->_objList[$index]; } public function set($index, $obj) { $this->_objList[$index] = $obj; } } // класс для хранения сотрудников class EmployeeList { // объект класса "список объектов" private $_employeersList; public function __construct(){ // создаём объект методы которого будем делегировать $this->_employeersList = new ObjectList; } public function getEmployer($index) { return $this->_employeersList->get($index); } public function setEmployer($index, Employee $objEmployer) { $this->_employeersList->set($index, $objEmployer); } public function __destruct() { $this->_employeersList->free(); } public function add(Employee $objEmployer) { $this->_employeersList->add($objEmployer); } public function remove(Employee $objEmployer) { $this->_employeersList->remove($objEmployer); } // последовательный поиск сотрудника по имени // через аргумент $offset можно задавать позицию с которой вести поиск. // если сотрудник не найден вернёт значение меньше ноля (-1) public function getIndexByName($name, $offset=0) { $result = -1; // предполагаем, что его нету в списке $cnt = $this->_employeersList->count(); for ($i = $offset; $i < $cnt; $i++) { if ( !strcmp( $name, $this->_employeersList->get($i)->getName() ) ) { $result = $i; break; } } return $result; } } $obj1 = new Employee("Танасийчук Степан", "web студия"); $obj2 = new Employee("Кусый Назар", "web студия"); $obj3 = new Employee("Сорока Орест", "web студия"); $objList = new EmployeeList(); $objList->add($obj1); $objList->add($obj2); $objList->add($obj3); echo "<pre>"; print_r($objList); echo "<hr>"; $index = $objList->getIndexByName("Кусый Назар"); $obj4 = $objList->getEmployer($index); print_r($obj4); echo "<hr>"; $objList->setEmployer(2, $obj4); print_r($objList); echo "</pre>";

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.0100.01018.40
8.3.50.0150.00522.11
8.3.40.0000.01518.79
8.3.30.0090.00620.17
8.3.20.0140.00420.39
8.3.10.0000.00922.09
8.3.00.0090.00022.31
8.2.180.0070.01018.39
8.2.170.0070.00722.96
8.2.160.0000.01622.25
8.2.150.0130.00324.18
8.2.140.0120.00624.66
8.2.130.0040.00426.16
8.2.120.0040.00419.54
8.2.110.0040.00422.21
8.2.100.0100.00519.57
8.2.90.0080.00019.29
8.2.80.0040.00419.21
8.2.70.0090.00017.63
8.2.60.0050.00317.93
8.2.50.0000.00818.07
8.2.40.0030.00518.05
8.2.30.0000.00718.20
8.2.20.0060.00317.68
8.2.10.0000.00817.70
8.2.00.0030.00817.64
8.1.280.0180.00025.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.79
8.1.230.0080.00419.10
8.1.220.0060.00317.76
8.1.210.0040.00418.77
8.1.200.0060.00317.38
8.1.190.0040.00417.53
8.1.180.0060.00319.01
8.1.170.0040.00418.62
8.1.160.0030.00622.06
8.1.150.0050.00518.70
8.1.140.0050.00317.56
8.1.130.0070.00017.75
8.1.120.0040.00417.52
8.1.110.0040.00417.51
8.1.100.0030.00517.34
8.1.90.0040.00417.48
8.1.80.0000.00717.52
8.1.70.0030.00517.50
8.1.60.0050.00317.66
8.1.50.0030.00517.60
8.1.40.0050.00317.45
8.1.30.0030.00617.48
8.1.20.0040.00417.69
8.1.10.0000.00817.62
8.1.00.0050.00317.54
8.0.300.0000.00818.77
8.0.290.0070.00017.05
8.0.280.0030.00318.40
8.0.270.0000.00717.28
8.0.260.0030.00316.87
8.0.250.0030.00317.07
8.0.240.0060.00316.98
8.0.230.0040.00417.06
8.0.220.0050.00316.91
8.0.210.0000.00717.00
8.0.200.0070.00017.08
8.0.190.0040.00317.01
8.0.180.0030.00617.01
8.0.170.0040.00416.89
8.0.160.0040.00416.92
8.0.150.0040.00416.95
8.0.140.0080.00016.92
8.0.130.0030.00313.45
8.0.120.0040.00416.93
8.0.110.0080.00016.80
8.0.100.0070.00016.79
8.0.90.0000.00816.84
8.0.80.0000.01516.95
8.0.70.0070.00017.03
8.0.60.0040.00417.02
8.0.50.0020.00516.97
8.0.30.0100.01116.86
8.0.20.0120.00817.40
8.0.10.0050.00217.21
8.0.00.0120.00816.92
7.4.330.0030.00315.00
7.4.320.0000.00616.63
7.4.300.0000.00616.61
7.4.290.0040.00416.52
7.4.280.0000.00816.42
7.4.270.0080.00016.64
7.4.260.0000.00716.57
7.4.250.0050.00216.58
7.4.240.0010.00616.52
7.4.230.0030.00316.46
7.4.220.0120.00616.64
7.4.210.0100.00516.62
7.4.200.0000.00716.64
7.4.190.0070.00016.59
7.4.160.0120.00416.64
7.4.150.0120.00617.40
7.4.140.0110.01017.86
7.4.130.0060.01616.57
7.4.120.0090.00816.55
7.4.110.0120.00616.75
7.4.100.0050.01416.41
7.4.90.0100.00716.62
7.4.80.0080.01119.39
7.4.70.0130.00316.54
7.4.60.0130.00716.44
7.4.50.0030.01216.24
7.4.40.0100.00718.39
7.4.30.0140.00515.97
7.4.20.0170.00316.02
7.4.10.0140.00715.60
7.4.00.0120.00715.71
7.3.330.0030.00313.39
7.3.320.0000.00613.34
7.3.310.0070.00016.26
7.3.300.0090.00016.33
7.3.290.0070.00716.41
7.3.280.0060.01116.38
7.3.270.0060.01017.40
7.3.260.0130.00316.44
7.3.250.0080.01016.40
7.3.240.0090.00916.64
7.3.230.0080.00816.49
7.3.210.0060.01316.57
7.3.200.0040.01419.39
7.3.190.0030.01716.67
7.3.180.0110.00716.43
7.3.170.0110.00716.34
7.3.160.0120.00616.37
7.3.150.0130.00815.89
7.3.140.0170.00416.07
7.3.130.0110.00715.71
7.3.120.0050.01415.35
7.3.110.0090.01015.33
7.3.100.0090.00915.88
7.3.90.0070.01115.51
7.3.80.0120.00515.53
7.3.70.0040.01415.41
7.3.60.0110.00815.52
7.3.50.0060.01315.52
7.3.40.0050.01315.60
7.3.30.0100.00915.52
7.3.20.0130.00917.37
7.3.10.0080.00817.21
7.3.00.0090.00917.14
7.2.330.0090.00916.93
7.2.320.0110.01116.57
7.2.310.0190.00416.61
7.2.300.0100.01016.23
7.2.290.0120.00616.40
7.2.280.0090.01416.11
7.2.270.0080.01116.42
7.2.260.0090.01015.75
7.2.250.0120.00815.74
7.2.240.0090.00815.71
7.2.230.0080.01115.79
7.2.220.0080.01615.72
7.2.210.0100.00615.83
7.2.200.0080.00815.83
7.2.190.0120.00615.53
7.2.180.0090.00915.88
7.2.170.0080.01115.79
7.2.160.0080.01015.84
7.2.150.0080.00817.69
7.2.140.0090.01017.55
7.2.130.0100.00917.46
7.2.120.0080.01317.52
7.2.110.0110.00817.60
7.2.100.0080.01017.50
7.2.90.0110.01317.68
7.2.80.0120.00917.50
7.2.70.0110.00717.52
7.2.60.0080.01017.32
7.2.50.0100.00917.61
7.2.40.0100.01017.66
7.2.30.0120.00617.62
7.2.20.0040.01217.75
7.2.10.0100.00717.61
7.2.00.0070.00918.22
7.1.330.0140.00716.59
7.1.320.0160.00816.52
7.1.310.0110.00916.56
7.1.300.0130.00716.44
7.1.290.0100.00716.71
7.1.280.0100.01016.43
7.1.270.0130.00816.40
7.1.260.0100.00816.46
7.1.250.0060.01316.45
7.1.240.0120.00816.49
7.1.230.0140.00416.63
7.1.220.0110.00516.43
7.1.210.0110.00816.30
7.1.200.0160.00716.15
7.1.190.0100.00816.59
7.1.180.0080.01216.41
7.1.170.0090.00616.29
7.1.160.0110.00716.48
7.1.150.0120.00916.53
7.1.140.0130.00616.47
7.1.130.0120.00816.41
7.1.120.0150.00616.64
7.1.110.0170.00616.59
7.1.100.0110.01117.19
7.1.90.0150.01016.45
7.1.80.0130.00916.64
7.1.70.0110.00716.91
7.1.60.0090.01217.60
7.1.50.0090.01516.79
7.1.40.0170.00616.63
7.1.30.0130.00816.60
7.1.20.0130.01016.62
7.1.10.0140.00716.64
7.1.00.0080.01718.50
7.0.330.0140.00816.06
7.0.320.0090.01216.04
7.0.310.0050.01416.10
7.0.300.0160.00716.08
7.0.290.0130.00915.79
7.0.280.0120.01016.27
7.0.270.0180.00516.30
7.0.260.0130.01116.27
7.0.250.0160.00916.15
7.0.240.0130.01216.31
7.0.230.0110.01016.31
7.0.220.0160.00416.39
7.0.210.0130.01216.27
7.0.200.0080.00916.49
7.0.190.0130.01116.17
7.0.180.0150.00816.28
7.0.170.0120.00916.21
7.0.160.0160.00516.24
7.0.150.0150.00716.21
7.0.140.0110.02918.23
7.0.130.0160.00716.33
7.0.120.0160.00816.24
7.0.110.0130.00816.26
7.0.100.0100.01016.32
7.0.90.0120.01216.11
7.0.80.0140.00616.21
7.0.70.1890.01917.60
7.0.60.0120.03617.51
7.0.50.0190.02816.83
7.0.40.0100.02316.95
7.0.30.0230.01616.96
7.0.20.0170.02616.91
7.0.10.0190.01916.95
7.0.00.0170.02816.83
5.6.400.0190.00515.35
5.6.390.0160.00915.25
5.6.380.0160.00815.32
5.6.370.0100.01315.11
5.6.360.0090.01415.21
5.6.350.0140.00715.39
5.6.340.0110.01215.32
5.6.330.0100.01415.45
5.6.320.0160.00915.38
5.6.310.0150.00815.49
5.6.300.0070.01615.25
5.6.290.0040.01415.18
5.6.280.0140.02717.26
5.6.270.0150.01015.37
5.6.260.0130.01115.22
5.6.250.0100.01315.48
5.6.240.0160.00715.33
5.6.230.0120.01615.34
5.6.220.0100.01315.22
5.6.210.0130.01617.04
5.6.200.0120.02516.12
5.6.190.0110.02217.02
5.6.180.0130.02617.12
5.6.170.0210.02916.97
5.6.160.0130.02417.28
5.6.150.0100.02116.24
5.6.140.0110.03516.24
5.6.130.0130.03116.22
5.6.120.0090.02717.42
5.6.110.0140.02717.24
5.6.100.0150.03117.24
5.6.90.0120.03417.27
5.6.80.0100.03717.00
5.6.70.0170.03216.92
5.6.60.0130.01215.28
5.6.50.0180.00815.28
5.6.40.0150.01115.27
5.6.30.0160.00715.21
5.6.20.0190.00815.24
5.6.10.0120.00915.33
5.6.00.0140.00815.29
5.5.380.0080.01415.24
5.5.370.0160.00715.27
5.5.360.0170.00715.32
5.5.350.0120.03116.99
5.5.340.0110.03316.11
5.5.330.0130.03216.96
5.5.320.0130.01916.90
5.5.310.0230.02816.89
5.5.300.0130.03016.16
5.5.290.0130.02116.20
5.5.280.0140.03317.16
5.5.270.0090.02917.16
5.5.260.0090.03817.08
5.5.250.0130.03217.07
5.5.240.0080.03416.89
5.5.230.0130.01115.32
5.5.220.0210.00615.19
5.5.210.0160.00815.21
5.5.200.0130.01115.30
5.5.190.0150.00815.28
5.5.180.0130.01215.06
5.5.170.0180.00515.21
5.5.160.0130.00815.21
5.5.150.0080.01415.21
5.5.140.0160.00915.03
5.5.130.0160.00715.28
5.5.120.0150.00815.08
5.5.110.0150.00815.32
5.5.100.0150.00715.06
5.5.90.0090.01215.11
5.5.80.0150.00715.27
5.5.70.0150.00815.06
5.5.60.0140.00915.02
5.5.50.0130.00815.06
5.5.40.0120.01114.93
5.5.30.0100.01214.88
5.5.20.0140.01015.28
5.5.10.0200.00315.22
5.5.00.0130.01115.15
5.4.450.0160.02214.63
5.4.440.0410.03614.88
5.4.430.0380.02314.78
5.4.420.0380.02714.92
5.4.410.0150.02414.68
5.4.400.0390.01814.67
5.4.390.0340.02514.74
5.4.380.0160.02414.49
5.4.370.0200.02514.49
5.4.360.0150.02414.55
5.4.350.0110.01812.40
5.4.340.0100.01912.32
5.4.330.0110.00912.57
5.4.320.0090.01912.49
5.4.310.0100.02012.44
5.4.300.0120.02112.45
5.4.290.0090.02612.46
5.4.280.0130.01612.44
5.4.270.0110.01912.52
5.4.260.0100.01812.46
5.4.250.0090.02112.42
5.4.240.0090.01112.51
5.4.230.0080.01212.49
5.4.220.0110.00612.40
5.4.210.0090.00712.39
5.4.200.0130.00612.46
5.4.190.0150.00412.43
5.4.180.0090.00912.53
5.4.170.0110.00812.42
5.4.160.0090.01012.46
5.4.150.0070.01212.50
5.4.140.0120.00512.39
5.4.130.0070.01312.45
5.4.120.0130.00912.37
5.4.110.0170.00712.49
5.4.100.0120.00612.49
5.4.90.0170.00512.44
5.4.80.0130.00912.41
5.4.70.0140.01112.45
5.4.60.0150.01112.48
5.4.50.0120.01012.42
5.4.40.0100.01112.44
5.4.30.0140.00412.45
5.4.20.0140.00712.47
5.4.10.0110.01112.47
5.4.00.0100.00712.48
5.3.290.0110.02212.71
5.3.280.0070.01112.67
5.3.270.0120.00612.61
5.3.260.0070.01412.71
5.3.250.0140.00612.71
5.3.240.0110.00912.58
5.3.230.0090.00912.65
5.3.220.0110.01112.69
5.3.210.0110.00912.58
5.3.200.0140.00712.57
5.3.190.0140.00612.61
5.3.180.0140.00912.81
5.3.170.0140.00512.67
5.3.160.0100.01112.76
5.3.150.0130.00812.81
5.3.140.0110.00612.65
5.3.130.0110.01312.67
5.3.120.0110.01112.66
5.3.110.0110.01012.67
5.3.100.0100.00812.69
5.3.90.0060.01412.70
5.3.80.0130.00612.58
5.3.70.0100.01012.57
5.3.60.0110.01012.58
5.3.50.0090.01312.66
5.3.40.0170.00212.56
5.3.30.0090.01012.69
5.3.20.0080.00912.66
5.3.10.0150.00212.56
5.3.00.0060.01212.51
5.2.170.0130.01312.09
5.2.160.0140.01112.10
5.2.150.0140.00712.09
5.2.140.0190.00312.09
5.2.130.0090.01212.10
5.2.120.0170.00512.14
5.2.110.0210.00412.16
5.2.100.0080.01612.02
5.2.90.0120.00811.96
5.2.80.0150.00812.05
5.2.70.0160.00612.03
5.2.60.0140.01011.82
5.2.50.0180.00511.88
5.2.40.0100.01312.09
5.2.30.0180.00812.07
5.2.20.0140.01111.88
5.2.10.0120.00811.74
5.2.00.0200.00311.82
5.1.60.0130.00811.19
5.1.50.0130.00911.14
5.1.40.0150.00311.13
5.1.30.0200.00011.21
5.1.20.0120.01211.26
5.1.10.0140.00511.27
5.1.00.0190.00210.96
5.0.50.0080.00810.18
5.0.40.0140.00610.14
5.0.30.0130.00710.14
5.0.20.0120.00610.14
5.0.10.0140.00610.14
5.0.00.0130.00710.14
4.4.90.0100.00010.14
4.4.80.0050.00510.14
4.4.70.0080.00010.14
4.4.60.0060.00210.14
4.4.50.0080.00010.14
4.4.40.0110.00010.14
4.4.30.0040.00410.14
4.4.20.0090.00010.14
4.4.10.0040.00410.14
4.4.00.0020.00610.14
4.3.110.0080.00310.14
4.3.100.0040.00410.14
4.3.90.0080.00310.14
4.3.80.0020.00910.14
4.3.70.0080.00410.14
4.3.60.0060.00610.14
4.3.50.0030.00610.14
4.3.40.0110.00010.14
4.3.30.0070.00210.14
4.3.20.0060.00210.14
4.3.10.0000.00710.14
4.3.00.0020.0158.76

preferences:
42.08 ms | 401 KiB | 5 Q