3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { public $id; public $name; public $phones = []; public function __construct($id, $name) { $this->id = $id; $this->name = $name; } public function addPhone($phone) { $this->phones[] = $phone; } } /** * @return Person[] */ function statementToPersonList(iterable $stmt): array { $personList = []; foreach ($stmt as $row) { $id = $row['id']; $name = $row['name']; $number = $row['number']; if (!isset($personList[$name])) { $personList[$name] = new Person($id, $name); } $personList[$name]->addPhone($number); } return $personList; } $personList = statementToPersonList([ ['id' => 1, 'name' => 'Alice', 'number' => 'n1'], ['id' => 2, 'name' => 'Alice', 'number' => 'n2'], ['id' => 3, 'name' => 'Bob', 'number' => 'n3'], ['id' => 4, 'name' => 'Carol', 'number' => 'n4'], ['id' => 5, 'name' => 'Alice', 'number' => 'n5'], ]); print_r($personList);

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.0110.01022.46
8.4.110.0120.00820.61
8.4.100.0130.00717.65
8.4.90.0100.01020.38
8.4.80.0070.00620.43
8.4.70.0110.00619.16
8.4.60.0110.00820.69
8.4.50.0120.00818.00
8.4.40.0110.00719.59
8.4.30.0060.01322.07
8.4.20.0180.00317.74
8.4.10.0040.01219.67
8.3.250.0120.00618.79
8.3.240.0070.00116.79
8.3.230.0100.00916.60
8.3.220.0120.00620.90
8.3.210.0090.00916.55
8.3.200.0060.00316.75
8.3.190.0130.00717.05
8.3.180.0140.00516.80
8.3.170.0040.01419.07
8.3.160.0100.00718.38
8.3.150.0100.01020.88
8.3.140.0080.00818.31
8.3.130.0040.00416.68
8.3.120.0000.00718.99
8.3.110.0060.01220.94
8.3.100.0160.00024.06
8.3.90.0040.00426.77
8.3.80.0050.00519.36
8.3.70.0060.01018.17
8.3.60.0220.00018.56
8.3.50.0140.00523.62
8.3.40.0110.00418.84
8.3.30.0000.01518.71
8.3.20.0070.00024.18
8.3.10.0040.00424.66
8.3.00.0000.00926.16
8.2.290.0150.00517.13
8.2.280.0150.00418.19
8.2.270.0070.01118.84
8.2.260.0040.00418.18
8.2.250.0050.00318.31
8.2.240.0040.00417.03
8.2.230.0060.00322.58
8.2.220.0120.00037.54
8.2.210.0000.00826.77
8.2.200.0000.01118.88
8.2.190.0100.01016.68
8.2.180.0120.00925.92
8.2.170.0040.01118.89
8.2.160.0100.00322.96
8.2.150.0050.00325.66
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0040.00426.35
8.2.110.0030.00622.29
8.2.100.0110.00017.97
8.2.90.0040.00417.97
8.2.80.0040.00419.12
8.2.70.0050.00317.63
8.2.60.0000.00817.63
8.2.50.0030.00517.55
8.2.40.0080.00017.75
8.2.30.0070.00318.11
8.2.20.0000.00818.10
8.2.10.0040.00419.29
8.2.00.0030.00619.30
8.1.330.0150.00316.24
8.1.320.0080.01017.79
8.1.310.0040.01216.82
8.1.300.0060.00318.36
8.1.290.0050.00530.84
8.1.280.0090.00925.92
8.1.270.0030.00523.99
8.1.260.0040.00428.09
8.1.250.0070.00028.09
8.1.240.0050.00520.88
8.1.230.0110.00020.97
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0080.00017.35
8.1.190.0080.00017.23
8.1.180.0040.00418.10
8.1.170.0040.00418.84
8.1.160.0080.00018.80
8.1.150.0000.00718.89
8.1.140.0070.00018.88
8.1.130.0030.00320.18
8.1.120.0070.00017.48
8.1.110.0000.00717.41
8.1.100.0070.00017.48
8.1.90.0050.00217.42
8.1.80.0030.00617.50
8.1.70.0030.00317.40
8.1.60.0040.00417.46
8.1.50.0050.00217.46
8.1.40.0040.00417.53
8.1.30.0000.00717.67
8.1.20.0060.00317.68
8.1.10.0000.00817.55
8.1.00.0000.00717.31
8.0.300.0000.00720.11
8.0.290.0080.00016.75
8.0.280.0040.00418.44
8.0.270.0070.00018.06
8.0.260.0000.00718.50
8.0.250.0000.00717.00
8.0.240.0030.00616.93
8.0.230.0000.00716.99
8.0.220.0050.00316.84
8.0.210.0070.00016.86
8.0.200.0000.00717.05
8.0.190.0020.00517.05
8.0.180.0040.00416.89
8.0.170.0000.00917.00
8.0.160.0040.00416.94
8.0.150.0030.00516.85
8.0.140.0050.00316.86
8.0.130.0000.00613.36
8.0.120.0040.00416.93
8.0.110.0050.00316.90
8.0.100.0080.00016.77
8.0.90.0000.00716.91
8.0.80.0060.01116.93
8.0.70.0030.00516.79
8.0.60.0050.00316.77
8.0.50.0020.00516.96
8.0.30.0160.00617.21
8.0.20.0120.00617.27
8.0.10.0000.00717.03
8.0.00.0030.01416.69
7.4.330.0000.00515.55
7.4.320.0000.00716.52
7.4.300.0030.00316.43
7.4.290.0060.00316.54
7.4.280.0040.00416.41
7.4.270.0040.00416.48
7.4.260.0060.00013.25
7.4.250.0000.00716.39
7.4.240.0040.00416.53
7.4.230.0040.00416.30
7.4.220.0000.00716.57
7.4.210.0100.00416.63
7.4.200.0070.00016.48
7.4.130.0130.00316.25
7.4.120.0130.00416.27
7.4.110.0060.01316.38
7.4.100.0030.01316.27
7.4.90.0100.00716.22
7.4.80.0030.01416.49
7.4.70.0100.01016.42
7.4.60.0120.00616.56
7.4.50.0160.00616.17
7.4.40.0100.01616.57
7.4.30.0150.00316.48
7.4.20.0110.01516.32
7.4.10.0150.00416.48
7.4.00.0140.00416.45
7.3.330.0030.00316.40
7.3.320.0050.00013.40
7.3.310.0070.00016.37
7.3.300.0080.00016.45
7.3.290.0050.00916.40
7.3.260.0140.00916.31
7.3.250.0100.00716.30
7.3.240.0070.01016.43
7.3.230.0150.00316.56
7.3.220.0100.00616.25
7.3.210.0070.01016.51
7.3.200.0100.01016.30
7.3.190.0100.00716.38
7.3.180.0120.00616.33
7.3.170.0160.01016.30
7.3.160.0100.00716.64
7.3.150.0120.01116.43
7.3.140.0120.00616.31
7.3.130.0150.00416.32
7.3.120.0080.00816.61
7.3.110.0080.01116.21
7.3.100.0150.00916.42
7.3.90.0130.00616.45
7.3.80.0090.00916.57
7.3.70.0100.00716.39
7.3.60.0100.00716.36
7.3.50.0070.01016.35
7.3.40.0130.00316.39
7.3.30.0120.00916.49
7.3.20.0060.01416.46
7.3.10.0120.00616.38
7.3.00.0170.00016.32

preferences:
28.22 ms | 403 KiB | 5 Q