3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeHelperClass { public $_arr = []; public function addValue($value, $key = null): void { if ($key !== null) { $this->_arr[$key] = $value; } elseif (!$this->_arr) { $this->_arr[] = $value; } else { $this->_arr[max(array_keys($this->_arr)) + 1] = $value; } } } $test = new SomeHelperClass; var_export($test->_arr); echo "\n"; $test->addValue(1); var_export($test->_arr); echo "\n"; $test->addValue(2); var_export($test->_arr); echo "\n"; $test->addValue(3, 4); var_export($test->_arr); echo "\n"; $test->addValue(4, 3); var_export($test->_arr); echo "\n"; $test->addValue(5); var_export($test->_arr);

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.0130.00720.56
8.4.110.0100.00922.37
8.4.100.0110.00917.78
8.4.90.0050.00418.86
8.4.80.0130.00817.61
8.4.70.0040.00417.85
8.4.60.0050.00418.94
8.4.50.0080.01318.85
8.4.40.0040.00417.67
8.4.30.0090.01320.82
8.4.20.0100.00624.37
8.4.10.0090.00023.82
8.3.250.0140.00518.92
8.3.240.0120.00816.62
8.3.230.0120.00716.64
8.3.220.0080.01017.34
8.3.210.0060.00216.68
8.3.200.0060.00316.59
8.3.190.0110.00717.38
8.3.180.0120.00816.72
8.3.170.0080.00019.10
8.3.160.0160.00316.62
8.3.150.0090.00918.89
8.3.140.0070.00716.64
8.3.130.0040.00418.30
8.3.120.0080.00018.91
8.3.110.0000.00820.94
8.3.100.0060.00318.56
8.3.90.0070.01116.66
8.3.80.0080.00318.43
8.3.70.0070.00718.28
8.3.60.0070.01416.50
8.3.50.0110.00416.85
8.3.40.0140.00320.22
8.3.30.0080.00818.81
8.3.20.0040.00424.18
8.3.10.0070.00024.66
8.3.00.0050.00326.16
8.2.290.0040.00520.48
8.2.280.0050.00318.54
8.2.270.0110.00717.32
8.2.260.0110.00716.36
8.2.250.0050.00316.71
8.2.240.0090.00017.34
8.2.230.0040.01222.58
8.2.220.0000.00724.06
8.2.210.0110.00426.77
8.2.200.0060.00316.75
8.2.190.0040.01116.58
8.2.180.0110.00416.32
8.2.170.0070.00718.70
8.2.160.0230.00022.96
8.2.150.0040.00425.66
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0030.00619.96
8.2.110.0050.00320.27
8.2.100.0110.00017.84
8.2.90.0040.00417.91
8.2.80.0000.00818.16
8.2.70.0000.00817.75
8.2.60.0040.00417.63
8.2.50.0030.00517.63
8.2.40.0110.00517.62
8.2.30.0110.00617.62
8.2.20.0120.00417.62
8.2.10.0140.00217.62
8.2.00.0120.00417.62
8.1.330.0080.00421.77
8.1.320.0110.00816.07
8.1.310.0040.00418.56
8.1.300.0030.00519.98
8.1.290.0070.00418.88
8.1.280.0100.00725.92
8.1.270.0030.00722.04
8.1.260.0000.00726.35
8.1.250.0000.00828.09
8.1.240.0030.00722.10
8.1.230.0070.00420.96
8.1.220.0030.00517.74
8.1.210.0080.00418.77
8.1.200.0080.00017.35
8.1.190.0000.00817.23
8.1.180.0060.00318.10
8.1.170.0080.00019.26
8.1.160.0110.00617.62
8.1.150.0130.00417.62
8.1.140.0120.00417.62
8.1.130.0110.00517.62
8.1.120.0080.00817.62
8.1.110.0050.00519.09
8.1.100.0090.00917.62
8.1.90.0120.00417.62
8.1.80.0110.00617.62
8.1.70.0080.00817.62
8.1.60.0190.00517.62
8.1.50.0120.00617.62
8.1.40.0130.00717.62
8.1.30.0090.00917.62
8.1.20.0090.00917.62
8.1.10.0120.00517.62
8.1.00.0180.00017.62
8.0.300.0040.00420.04
8.0.290.0000.00816.63
8.0.280.0150.00317.62
8.0.270.0160.00017.62
8.0.260.0170.00017.62
8.0.250.0130.00417.62
8.0.240.0080.00817.62
8.0.230.0100.00717.62
8.0.220.0110.00517.62
8.0.210.0120.00417.62
8.0.200.0110.00717.62
8.0.190.0100.00717.62
8.0.180.0120.00417.62
8.0.170.0080.00817.62
8.0.160.0120.00517.62
8.0.150.0140.00517.62
8.0.140.0110.00517.62
8.0.130.0110.00817.62
8.0.120.0140.00517.62
8.0.110.0170.00017.62
8.0.100.0110.00517.62
8.0.90.0120.00417.62
8.0.80.0120.00417.62
8.0.70.0120.00617.62
8.0.60.0120.00417.62
8.0.50.0150.00317.62
8.0.30.0170.00017.62
8.0.20.0080.00817.62
8.0.10.0110.00517.62

preferences:
53.72 ms | 403 KiB | 5 Q