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('1'); runTest('0'); runTest(3); runTest(1); runTest(0); runTest(null); runTest('');

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.0160.00318.39
8.3.50.0110.00921.21
8.3.40.0100.00618.87
8.3.30.0090.00618.68
8.3.20.0130.00618.82
8.3.10.0000.00820.96
8.3.00.0050.00321.91
8.2.180.0070.00716.50
8.2.170.0150.00022.96
8.2.160.0120.00320.51
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0070.00021.04
8.2.110.0060.00320.49
8.2.100.0110.00017.84
8.2.90.0080.00019.21
8.2.80.0050.00317.97
8.2.70.0000.00917.50
8.2.60.0040.00417.93
8.2.50.0040.00518.07
8.2.40.0040.00418.22
8.2.30.0070.00019.48
8.2.20.0000.00817.64
8.2.10.0090.00017.79
8.2.00.0050.00517.89
8.1.280.0080.00825.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.00622.06
8.1.230.0120.00017.58
8.1.220.0000.00917.78
8.1.210.0060.00318.77
8.1.200.0040.00417.35
8.1.190.0060.00317.53
8.1.180.0040.00418.10
8.1.170.0030.00618.64
8.1.160.0000.00718.92
8.1.150.0040.00718.67
8.1.140.0000.00717.43
8.1.130.0070.00017.92
8.1.120.0070.00017.52
8.1.110.0040.00417.41
8.1.100.0000.00717.52
8.1.90.0020.00517.50
8.1.80.0000.00817.47
8.1.70.0000.00717.42
8.1.60.0030.00617.59
8.1.50.0040.00417.57
8.1.40.0000.00817.45
8.1.30.0060.00317.71
8.1.20.0030.00517.55
8.1.10.0030.00517.55
8.1.00.0060.00317.45
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0000.00718.49
8.0.270.0040.00417.29
8.0.260.0000.00716.83
8.0.250.0050.00316.89
8.0.240.0050.00516.90
8.0.230.0040.00417.00
8.0.220.0020.00516.93
8.0.210.0080.00016.93
8.0.200.0060.00016.89
8.0.190.0000.00716.97
8.0.180.0050.00316.95
8.0.170.0070.00017.04
8.0.160.0040.00416.99
8.0.150.0070.00016.93
8.0.140.0000.00816.89
8.0.130.0060.00013.41
8.0.120.0070.00016.97
8.0.110.0040.00417.05
8.0.100.0040.00416.94
8.0.90.0040.00416.84
8.0.80.0120.00316.97
8.0.70.0000.00816.82
8.0.60.0050.00317.02
8.0.50.0040.00416.80
8.0.30.0090.01417.30
8.0.20.0180.01517.46
8.0.10.0030.00616.93
8.0.00.0080.01216.65
7.4.330.0000.00616.66
7.4.320.0060.00316.61
7.4.300.0030.00316.60
7.4.290.0000.00816.57
7.4.280.0000.00716.41
7.4.270.0000.00716.48
7.4.260.0000.00613.27
7.4.250.0040.00416.43
7.4.240.0080.00016.55
7.4.230.0050.00216.35
7.4.220.0120.00916.58
7.4.210.0070.00816.54
7.4.200.0070.00016.47
7.4.190.0030.00316.50
7.4.160.0120.00416.51
7.4.150.0130.01017.40
7.4.140.0080.01017.86
7.4.130.0080.00916.63
7.4.120.0110.00616.67
7.4.110.0180.00016.53
7.4.100.0140.00316.68
7.4.90.0090.00916.59
7.4.80.0160.00719.39
7.4.70.0140.00416.53
7.4.60.0100.00716.64
7.4.50.0080.00016.63
7.4.40.0050.00622.77
7.4.30.0040.01516.57
7.4.10.0100.01015.13
7.4.00.0070.00914.82
7.3.330.0060.00013.38
7.3.320.0050.00013.21
7.3.310.0020.00516.36
7.3.300.0040.00416.37
7.3.290.0110.00316.38
7.3.280.0090.00616.38
7.3.270.0060.01317.40
7.3.260.0120.01018.24
7.3.250.0080.01316.46
7.3.240.0130.01016.33
7.3.230.0140.00716.45
7.3.210.0070.01016.39
7.3.200.0150.01119.39
7.3.190.0090.00916.68
7.3.180.0100.00616.71
7.3.170.0100.01016.32
7.3.160.0050.01116.68
7.3.130.0030.01614.78
7.3.120.0060.00814.81
7.3.110.0030.01315.11
7.3.100.0030.01414.63
7.3.90.0120.00315.10
7.3.80.0030.01014.84
7.3.70.0000.01515.07
7.3.60.0040.00714.97
7.3.50.0040.00414.83
7.3.40.0000.01414.94
7.3.30.0080.00514.82
7.3.20.0000.00916.55
7.3.10.0000.01316.80
7.3.00.0030.00716.65
7.2.330.0090.00916.75
7.2.320.0090.01016.81
7.2.310.0160.00316.70
7.2.300.0120.00616.73
7.2.290.0070.01016.74
7.2.260.0040.01515.18
7.2.250.0070.01015.21
7.2.240.0000.01515.09
7.2.230.0060.01215.25
7.2.220.0030.01615.12
7.2.210.0120.00315.35
7.2.200.0090.00315.28
7.2.190.0060.00314.94
7.2.180.0000.00915.27
7.2.170.0070.00715.23
7.2.160.0040.00815.25
7.2.150.0090.00616.93
7.2.140.0110.00717.04
7.2.130.0000.01616.84
7.2.120.0030.01316.93
7.2.110.0070.00316.98
7.2.100.0110.00416.98
7.2.90.0080.00416.80
7.2.80.0000.01416.86
7.2.70.0070.00717.05
7.2.60.0130.00317.10
7.2.50.0070.00717.09
7.2.40.0030.00617.12
7.2.30.0060.00916.77
7.2.20.0050.00516.83
7.2.10.0000.00917.07
7.2.00.0020.01218.26
7.1.330.0030.01315.85
7.1.320.0040.01115.68
7.1.310.0030.01315.61
7.1.300.0040.01115.94
7.1.290.0080.00615.66
7.1.280.0030.01015.82
7.1.270.0000.01415.77
7.1.260.0030.00615.93
7.1.250.0120.00315.79
7.1.240.0030.01015.91
7.1.230.0000.01015.60
7.1.220.0110.00415.80
7.1.210.0120.00015.80
7.1.200.0070.00716.00
7.1.190.0060.00615.79
7.1.180.0050.00516.05
7.1.170.0030.00715.95
7.1.160.0030.01015.79
7.1.150.0040.00815.83
7.1.140.0000.01115.93
7.1.130.0040.00715.81
7.1.120.0090.00615.96
7.1.110.0090.00615.79
7.1.100.0020.01016.97
7.1.90.0000.01515.59
7.1.80.0080.00415.70
7.1.70.0060.00616.39
7.1.60.0080.01217.60
7.1.50.0050.00816.29
7.1.40.0000.01015.68
7.1.30.0030.01015.68
7.1.20.0040.00715.62
7.1.10.0040.00815.84
7.1.00.0050.02019.23
7.0.330.0070.00715.45
7.0.320.0130.00015.44
7.0.310.0070.00315.45
7.0.300.0030.00615.47
7.0.290.0000.01015.63
7.0.280.0070.00415.47
7.0.270.0050.00515.52
7.0.260.0070.01015.53
7.0.250.0060.00915.51
7.0.240.0000.01415.30
7.0.230.0040.00715.52
7.0.220.0000.01515.54
7.0.210.0150.00015.48
7.0.200.0060.00516.02
7.0.190.0000.00815.41
7.0.180.0000.01315.61
7.0.170.0070.00715.51
7.0.160.0030.00615.48
7.0.150.0000.01315.14
7.0.140.0080.03818.77
7.0.130.0060.00615.64
7.0.120.0000.01015.31
7.0.110.0030.01315.55
7.0.100.0060.00915.39
7.0.90.0220.05117.73
7.0.80.0350.04017.74
7.0.70.0300.04117.59
7.0.60.0370.03717.74
7.0.50.0250.04717.99
7.0.40.0040.03316.85
7.0.30.0080.04016.80
7.0.20.0050.04616.72
7.0.10.0070.04716.81
7.0.00.0030.04916.71
5.6.400.0110.00414.56
5.6.390.0060.00914.18
5.6.380.0110.00614.44
5.6.370.0030.01014.87
5.6.360.0040.01114.73
5.6.350.0120.00314.46
5.6.340.0000.01314.77
5.6.330.0030.00714.52
5.6.320.0090.01214.36
5.6.310.0030.01014.68
5.6.300.0120.00314.32
5.6.290.0070.00414.45
5.6.280.0070.03917.65
5.6.270.0060.01014.34
5.6.260.0070.01114.46
5.6.250.0030.01314.39
5.6.240.0040.01114.61
5.6.230.0060.04317.63
5.6.220.0100.04317.60
5.6.210.0080.03317.52
5.6.200.0230.03717.82
5.6.190.0130.02317.75
5.6.180.0060.04117.79
5.6.170.0070.04317.70
5.6.160.0030.04317.66
5.6.150.0120.03717.80
5.6.140.0050.04717.74
5.6.130.0080.04217.68
5.6.120.0080.02717.83
5.6.110.0100.03717.74
5.6.100.0030.03717.70
5.6.90.0050.04917.84
5.6.80.0120.03817.39
5.6.70.0120.04017.42
5.6.60.0080.04517.49
5.6.50.0030.04917.40
5.6.40.0050.04117.58
5.6.30.0030.03217.31
5.6.20.0050.04317.32
5.6.10.0070.03717.29
5.6.00.0080.03217.45
5.5.380.0090.00614.65
5.5.370.0100.03017.50
5.5.360.0070.04717.36
5.5.350.0100.04917.56
5.5.340.0050.03517.49
5.5.330.0050.04517.62
5.5.320.0100.04017.63
5.5.310.0150.02517.66
5.5.300.0050.05017.75
5.5.290.0080.03217.57
5.5.280.0070.03417.62
5.5.270.0030.04617.46
5.5.260.0070.03617.74
5.5.250.0100.04117.65
5.5.240.0040.02917.27
5.5.230.0080.04017.25
5.5.220.0080.04517.23
5.5.210.0030.04317.21
5.5.200.0120.03817.36
5.5.190.0100.03117.19
5.5.180.0110.03817.16
5.5.170.0090.00614.46
5.5.160.0070.04217.29
5.5.150.0030.04517.20
5.5.140.0000.04617.20
5.5.130.0080.03017.20
5.5.120.0030.03717.24
5.5.110.0070.04217.14
5.5.100.0080.02017.12
5.5.90.0060.04117.25
5.5.80.0140.02517.18
5.5.70.0120.03217.16
5.5.60.0060.04817.13
5.5.50.0090.03117.25
5.5.40.0060.04317.09
5.5.30.0080.02317.35
5.5.20.0100.03517.12
5.5.10.0080.02217.04
5.5.00.0070.03717.05
5.4.450.0070.02215.36
5.4.440.0090.02715.34
5.4.430.0050.04415.40
5.4.420.0070.04515.43
5.4.410.0100.03515.37
5.4.400.0070.04115.22
5.4.390.0080.03515.28
5.4.380.0080.04215.22
5.4.370.0070.04015.11
5.4.360.0140.03715.15
5.4.350.0030.04415.26
5.4.340.0060.03615.24
5.4.330.0100.00311.35
5.4.320.0070.04115.32
5.4.310.0090.03715.15
5.4.300.0050.04215.25
5.4.290.0050.03515.15
5.4.280.0080.03415.24
5.4.270.0070.03915.25
5.4.260.0060.03115.20
5.4.250.0000.02615.19
5.4.240.0080.03515.17
5.4.230.0060.03315.29
5.4.220.0120.03315.19
5.4.210.0040.04415.32
5.4.200.0080.04015.22
5.4.190.0070.02915.19
5.4.180.0050.03115.26
5.4.170.0080.02515.11
5.4.160.0090.02315.23
5.4.150.0070.03215.11
5.4.140.0030.02113.93
5.4.130.0020.02413.87
5.4.120.0050.02513.93
5.4.110.0030.02113.96
5.4.100.0040.02213.87
5.4.90.0040.02213.97
5.4.80.0020.02313.93
5.4.70.0070.02213.95
5.4.60.0050.02213.90
5.4.50.0050.02013.90
5.4.40.0050.01713.82
5.4.30.0030.03013.90
5.4.20.0070.01713.89
5.4.10.0010.02113.88
5.4.00.0060.02013.57
5.3.290.0030.03213.04
5.3.280.0050.02712.97
5.3.270.0080.01813.06
5.3.260.0050.02212.97
5.3.250.0000.02613.01
5.3.240.0070.02112.98
5.3.230.0050.02813.03
5.3.220.0060.02212.96
5.3.210.0080.01812.98
5.3.200.0070.03012.97
5.3.190.0050.03513.01
5.3.180.0050.02113.03
5.3.170.0040.02613.02
5.3.160.0040.04013.00
5.3.150.0050.03013.02
5.3.140.0080.01512.95
5.3.130.0020.02312.94
5.3.120.0020.02513.00
5.3.110.0000.02312.96
5.3.100.0050.02112.67
5.3.90.0120.03512.74
5.3.80.0040.02512.66
5.3.70.0050.03212.72
5.3.60.0030.02712.65
5.3.50.0070.02312.68
5.3.40.0030.01812.68
5.3.30.0050.01912.64
5.3.20.0050.01812.52
5.3.10.0020.01812.51
5.3.00.0000.02912.53
5.2.170.0000.03313.68
5.2.160.0000.03013.68
5.2.150.0000.05313.68
5.2.140.0000.02713.68
5.2.130.0030.04313.68
5.2.120.0030.03013.68
5.2.110.0030.03013.68
5.2.100.0000.02713.68
5.2.90.0030.03313.68
5.2.80.0070.06013.68
5.2.70.0070.03713.68
5.2.60.0000.02713.68
5.2.50.0070.05013.68
5.2.40.0030.02313.68
5.2.30.0000.04313.68
5.2.20.0000.02713.68
5.2.10.0100.01713.68
5.2.00.0030.02713.68
5.1.60.0030.02313.68
5.1.50.0000.02713.68
5.1.40.0030.02313.68
5.1.30.0030.02313.68
5.1.20.0070.02013.68
5.1.10.0000.02713.68
5.1.00.0000.02713.68
5.0.50.0030.02713.68
5.0.40.0000.02713.68
5.0.30.0030.04313.68
5.0.20.0000.05013.68
5.0.10.0100.03713.68
5.0.00.0100.05313.68
4.4.90.0030.02013.68
4.4.80.0000.01313.68
4.4.70.0000.01713.68
4.4.60.0000.01313.68
4.4.50.0000.01713.68
4.4.40.0030.02313.68
4.4.30.0000.01713.68
4.4.20.0030.01013.68
4.4.10.0070.02313.68
4.4.00.0030.04713.68
4.3.110.0030.03313.68
4.3.100.0030.03713.68
4.3.90.0070.02013.68
4.3.80.0030.04013.68
4.3.70.0000.03713.68
4.3.60.0070.03013.68
4.3.50.0030.03313.68
4.3.40.0030.03713.68
4.3.30.0100.03013.68
4.3.20.0030.03013.68
4.3.10.0000.03713.68
4.3.00.0000.03013.68

preferences:
47.35 ms | 401 KiB | 5 Q