3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); function getCollectionParentIDFromChildID($cID) { if(is_numeric($cID)) { if($cID > 1) { return '1'; } if($cID == 1) { return '0'; } } return null; } function populateParentIDArray_current($cID) { global $cParentIDArray; $cParentID = getCollectionParentIDFromChildID($cID); if($cParentID > -1) { if(!in_array($cParentID, $cParentIDArray)) { $cParentIDArray[] = $cParentID; } populateParentIDArray_current($cParentID); } } function populateParentIDArray_new($cID) { global $cParentIDArray; $cParentID = getCollectionParentIDFromChildID($cID); if(is_numeric($cParentID)) { if(!in_array($cParentID, $cParentIDArray)) { $cParentIDArray[] = $cParentID; } if($cParentID > 0) { populateParentIDArray_new($cParentID); } } } function runTest($cID) { global $cParentIDArray; echo "Test case for "; var_dump($cID); $cParentIDArray = array(); populateParentIDArray_current($cID); ob_start(); var_dump($cParentIDArray); $current = ob_get_contents(); ob_end_clean(); $cParentIDArray = array(); populateParentIDArray_new($cID); ob_start(); var_dump($cParentIDArray); $new = ob_get_contents(); ob_end_clean(); if($current === $new) { echo "Passed. Result: ", $current; } else { echo "###ERROR\nCURRENT: ", $current, "\nNEW: ", $new, "\n"; } echo "\n\n"; } runTest('3'); runTest(3); runTest('1'); runTest(1); runTest('0'); runTest(0); runTest('-1'); runTest(-1); runTest(null); runTest(''); runTest(false);

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.40.0110.01118.67
8.3.30.0070.01118.85
8.3.20.0000.00818.73
8.3.10.0050.00520.53
8.3.00.0080.00019.38
8.2.170.0110.01122.96
8.2.160.0030.01021.07
8.2.150.0040.00424.18
8.2.140.0000.00924.66
8.2.130.0060.00326.16
8.2.120.0050.00319.96
8.2.110.0070.00321.04
8.2.100.0060.00617.72
8.2.90.0030.00720.95
8.2.80.0040.00417.93
8.2.70.0050.00317.48
8.2.60.0090.00018.01
8.2.50.0060.00318.07
8.2.40.0000.00818.34
8.2.30.0060.00318.23
8.2.20.0050.00217.64
8.2.10.0040.00417.84
8.2.00.0040.00417.78
8.1.270.0000.00823.99
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00322.57
8.1.230.0040.00821.03
8.1.220.0060.00317.79
8.1.210.0040.00418.90
8.1.200.0030.00617.36
8.1.190.0080.00017.18
8.1.180.0000.00918.10
8.1.170.0050.00318.84
8.1.160.0070.00018.92
8.1.150.0060.00318.56
8.1.140.0080.00017.46
8.1.130.0040.00417.88
8.1.120.0040.00417.56
8.1.110.0050.00317.39
8.1.100.0040.00417.51
8.1.90.0030.00617.54
8.1.80.0030.00517.54
8.1.70.0000.00717.46
8.1.60.0040.00417.64
8.1.50.0000.00817.48
8.1.40.0000.00717.56
8.1.30.0070.00017.64
8.1.20.0050.00317.64
8.1.10.0050.00317.52
8.1.00.0030.00517.48
8.0.300.0000.00720.14
8.0.290.0040.00416.88
8.0.280.0000.00718.40
8.0.270.0030.00317.31
8.0.260.0000.00816.88
8.0.250.0050.00317.02
8.0.240.0080.00016.98
8.0.230.0070.00016.97
8.0.220.0070.00016.92
8.0.210.0000.00716.91
8.0.200.0030.00316.89
8.0.190.0080.00017.04
8.0.180.0000.00716.90
8.0.170.0040.00416.91
8.0.160.0070.00017.03
8.0.150.0030.00616.92
8.0.140.0020.00616.93
8.0.130.0050.00013.33
8.0.120.0050.00216.86
8.0.110.0030.00516.93
8.0.100.0070.00016.90
8.0.90.0050.00316.94
8.0.80.0130.00716.95
8.0.70.0070.00017.00
8.0.60.0030.00516.78
8.0.50.0030.00516.89
8.0.30.0150.00817.11
8.0.20.0170.00517.08
8.0.10.0050.00316.88
8.0.00.0110.00816.96
7.4.330.0000.00513.04
7.4.320.0030.00316.57
7.4.300.0040.00416.62
7.4.290.0030.00316.46
7.4.280.0030.00516.63
7.4.270.0000.00716.54
7.4.260.0030.00313.30
7.4.250.0040.00416.47
7.4.240.0030.00516.55
7.4.230.0030.00316.35
7.4.220.0120.01216.59
7.4.210.0060.01116.62
7.4.200.0000.00716.35
7.4.190.0000.00716.36
7.4.160.0040.01816.58
7.4.150.0030.01516.36
7.4.140.0120.00716.73
7.4.130.0130.00316.52
7.4.120.0100.00816.59
7.4.110.0060.01216.43
7.4.100.0120.00616.42
7.4.90.0050.01316.62
7.4.80.0080.00816.46
7.4.70.0110.00716.41
7.4.60.0080.01016.40
7.4.50.0000.00916.49
7.4.40.0090.00916.29
7.4.30.0060.00916.55
7.4.00.0030.01015.16
7.3.330.0030.00313.27
7.3.320.0000.00513.20
7.3.310.0060.00316.44
7.3.300.0030.00316.43
7.3.290.0140.00016.42
7.3.280.0050.01016.39
7.3.270.0160.00816.51
7.3.260.0180.00316.54
7.3.250.0150.00616.53
7.3.240.0120.00416.31
7.3.230.0070.01316.53
7.3.210.0130.00716.57
7.3.200.0090.00919.39
7.3.190.0040.01516.27
7.3.180.0030.01316.70
7.3.170.0080.00816.43
7.3.160.0090.00616.61
7.3.120.0040.00814.78
7.2.330.0160.00616.77
7.2.320.0120.00616.83
7.2.310.0170.00316.83
7.2.300.0060.01216.55
7.2.290.0070.01116.70
7.2.00.0000.01319.54
7.1.200.0030.00916.01
7.1.70.0080.00017.19
7.1.60.0120.01219.40
7.1.50.0100.01016.70
7.1.00.0030.07722.40
7.0.200.0030.00716.55
7.0.140.0070.07021.99
7.0.120.0070.07322.18
7.0.60.0070.06721.66
7.0.50.0100.04317.89
7.0.40.0130.05720.30
7.0.30.0200.03720.10
7.0.20.0300.06720.06
7.0.10.0000.09720.15
7.0.00.0070.04720.33
5.6.280.0030.07720.87
5.6.210.0100.05720.51
5.6.200.0070.04018.28
5.6.190.0100.08320.33
5.6.180.1000.04720.61
5.6.170.0200.03720.44
5.6.160.0170.05020.71
5.6.150.0030.08318.19
5.6.140.0000.09018.24
5.6.130.0100.03718.23
5.6.120.0070.08721.03
5.6.110.0100.04720.98
5.6.100.0100.06321.02
5.6.90.0100.08320.98
5.6.80.0030.07720.30
5.5.350.0000.06720.42
5.5.340.0070.03717.96
5.5.330.0100.09020.27
5.5.320.0270.08020.51
5.5.310.0230.08320.29
5.5.300.0070.03717.95
5.5.290.0100.04017.98
5.5.280.0100.08020.78
5.5.270.0170.07320.85
5.5.260.0070.09020.66
5.5.250.0070.09020.70
5.5.240.0130.07720.23
5.4.450.0070.04719.57
5.4.440.0130.07319.47
5.4.430.0070.04719.44
5.4.420.0000.04319.56
5.4.410.0030.08019.35
5.4.400.0070.04719.08
5.4.390.0000.04319.14
5.4.380.0100.04019.15
5.4.370.0200.06719.12
5.4.360.0200.07018.85
5.4.350.0070.03718.87
5.4.340.0030.07719.16
5.4.320.0070.06018.98
5.4.310.0030.08019.24
5.4.300.0130.05319.24
5.4.290.0100.03719.14
5.4.280.0170.05718.85
5.4.270.0100.07319.20
5.4.260.0170.05318.87
5.4.250.0100.04718.96
5.4.240.0170.03719.00
5.4.230.0030.07319.05
5.4.220.0030.04019.15
5.4.210.0170.06719.14
5.4.200.0100.03719.19
5.4.190.0070.07719.23
5.4.180.0030.07019.18
5.4.170.0100.07719.14
5.4.160.0130.05719.15
5.4.150.0070.04319.18
5.4.140.0130.07016.48
5.4.130.0130.03716.59
5.4.120.0030.07316.31
5.4.110.0170.06716.42
5.4.100.0100.06316.44
5.4.90.0000.05316.39
5.4.80.0030.06716.46
5.4.70.0030.03716.44
5.4.60.0100.07016.51
5.4.50.0070.07016.40
5.4.40.0070.07016.40
5.4.30.0000.06016.35
5.4.20.0170.05316.40
5.4.10.0170.06316.45
5.4.00.0070.04015.75
5.3.290.0030.08014.61
5.3.280.0100.07314.63
5.3.270.0070.07714.68
5.3.260.0130.07314.67
5.3.250.0000.07714.66
5.3.240.0100.07014.64
5.3.230.0100.06314.61
5.3.220.0100.06014.59
5.3.210.0170.05314.59
5.3.200.0070.07314.63
5.3.190.0070.04014.58
5.3.180.0030.06014.59
5.3.170.0030.08014.58
5.3.160.0070.06314.57
5.3.150.0100.07714.64
5.3.140.0000.07314.60
5.3.130.0100.07314.48
5.3.120.0130.06714.64
5.3.110.0130.07314.59
5.3.100.0130.06714.20
5.3.90.0070.07714.11
5.3.80.0130.04313.96
5.3.70.0070.07713.98
5.3.60.0030.07714.02
5.3.50.0070.07013.91
5.3.40.0100.03714.02
5.3.30.0000.04013.88
5.3.20.0100.07313.73
5.3.10.0070.06013.70
5.3.00.0170.06713.58
5.2.170.0130.04711.32
5.2.160.0070.06311.05
5.2.150.0000.07011.18
5.2.140.0070.03311.18
5.2.130.0030.04711.17
5.2.120.0070.06011.04
5.2.110.0030.06011.19
5.2.100.0030.04011.07
5.2.90.0030.06011.20
5.2.80.0070.02711.06
5.2.70.0030.04711.08
5.2.60.0070.06011.00
5.2.50.0100.05011.09
5.2.40.0070.06010.94
5.2.30.0070.04310.95
5.2.20.0030.04010.94
5.2.10.0070.04710.88
5.2.00.0130.05310.88
5.1.60.0030.05010.00
5.1.50.0000.05010.01
5.1.40.0000.03710.15
5.1.30.0070.02710.35
5.1.20.0030.05710.42
5.1.10.0100.05310.11
5.1.00.0130.04010.06
5.0.50.0130.0308.54
5.0.40.0030.0478.43
5.0.30.0000.0608.29
5.0.20.0070.0438.19
5.0.10.0100.0378.10
5.0.00.0000.0608.09
4.4.90.0000.0407.82
4.4.80.0030.0307.82
4.4.70.0030.0207.82
4.4.60.0000.0277.82
4.4.50.0070.0177.82
4.4.40.0000.0577.82
4.4.30.0000.0237.82
4.4.20.0000.0277.82
4.4.10.0030.0377.82
4.4.00.0000.0607.82
4.3.110.0070.0307.82
4.3.100.0030.0337.82
4.3.90.0070.0277.82
4.3.80.0030.0337.82
4.3.70.0030.0337.82
4.3.60.0000.0237.82
4.3.50.0030.0237.82
4.3.40.0070.0237.82
4.3.30.0030.0137.82
4.3.20.0030.0137.82
4.3.10.0070.0107.82
4.3.00.0000.0177.82

preferences:
44.63 ms | 400 KiB | 5 Q