3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a= array ( 1 => 0, 2 => 1, 3 => 2, 4 => 3, 5 => 1, 6 => 0 ); class node { var $children; public function __construct(){ $this->children = array(); } } $tree = array(); foreach ($a as $q => $p){ if(!isset($tree[$p])) $tree[$p] = new node; if(!isset($tree[$q])) $tree[$q] = new node; $mark[$p]=FALSE; $mark[$q]=FALSE; array_push($tree[$p]->children,$q); } function dfs(&$ans,$node){ global $tree, $mark; $mark[$node] = TRUE; $ans = array(); foreach($tree[$node]->children as $child) if(!$mark[$child]){ $ans[$child]=$child; dfs($ans[$child],$child); } } $parent=1; dfs($ans,$parent); print_r($ans[0]); ?>

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.0070.00716.88
8.3.50.0140.00621.93
8.3.40.0090.00619.05
8.3.30.0100.00719.22
8.3.20.0040.00420.39
8.3.10.0080.00023.41
8.3.00.0040.00719.50
8.2.180.0120.00318.16
8.2.170.0160.00322.96
8.2.160.0090.00920.43
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0070.00026.16
8.2.120.0080.00022.06
8.2.110.0060.00322.00
8.2.100.0000.01319.43
8.2.90.0000.00819.21
8.2.80.0040.00417.97
8.2.70.0000.00917.75
8.2.60.0000.00817.77
8.2.50.0040.00418.07
8.2.40.0080.00019.76
8.2.30.0040.00418.05
8.2.20.0060.00317.79
8.2.10.0040.00418.04
8.2.00.0040.00417.78
8.1.280.0040.01125.92
8.1.270.0000.00823.88
8.1.260.0070.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00421.98
8.1.230.0090.00319.05
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0030.00617.25
8.1.190.0000.00817.35
8.1.180.0030.00718.10
8.1.170.0030.00618.53
8.1.160.0040.00422.02
8.1.150.0070.00318.68
8.1.140.0000.00717.37
8.1.130.0000.00717.85
8.1.120.0040.00417.53
8.1.110.0040.00417.54
8.1.100.0000.00717.55
8.1.90.0000.00717.40
8.1.80.0040.00417.36
8.1.70.0030.00517.39
8.1.60.0060.00317.62
8.1.50.0030.00617.51
8.1.40.0060.00317.63
8.1.30.0050.00317.52
8.1.20.0000.00717.76
8.1.10.0000.00717.55
8.1.00.0000.00817.59
8.0.300.0070.00018.77
8.0.290.0040.00417.18
8.0.280.0000.00818.43
8.0.270.0070.00017.17
8.0.260.0030.00317.20
8.0.250.0030.00316.93
8.0.240.0030.00617.01
8.0.230.0070.00017.06
8.0.220.0030.00316.91
8.0.210.0040.00416.90
8.0.200.0000.00717.10
8.0.190.0000.00816.92
8.0.180.0050.00317.05
8.0.170.0090.00016.99
8.0.160.0000.00717.06
8.0.150.0040.00416.91
8.0.140.0060.00316.85
8.0.130.0030.00313.38
8.0.120.0040.00416.86
8.0.110.0050.00316.90
8.0.100.0060.00317.04
8.0.90.0000.00716.80
8.0.80.0030.01216.95
8.0.70.0040.00416.85
8.0.60.0040.00417.03
8.0.50.0040.00416.98
8.0.30.0110.00817.15
8.0.20.0050.01517.40
8.0.10.0040.00417.11
8.0.00.0040.01416.69
7.4.330.0000.00515.09
7.4.320.0050.00216.50
7.4.300.0030.00316.64
7.4.290.0000.00716.53
7.4.280.0040.00416.43
7.4.270.0040.00416.68
7.4.260.0030.00316.55
7.4.250.0040.00416.65
7.4.240.0030.00516.55
7.4.230.0070.00016.64
7.4.220.0090.00916.64
7.4.210.0060.01016.60
7.4.200.0000.00716.59
7.4.190.0040.00316.73
7.4.160.0160.00016.82
7.4.150.0140.00317.40
7.4.140.0130.00917.86
7.4.130.0110.00516.50
7.4.120.0050.01116.63
7.4.110.0130.01016.72
7.4.100.0160.01016.75
7.4.90.0090.00916.45
7.4.80.0170.00319.39
7.4.70.0060.01216.61
7.4.60.0130.00316.36
7.4.50.0040.00416.57
7.4.40.0130.00916.63
7.4.30.0030.01416.51
7.4.00.0060.00914.95
7.3.330.0040.00413.28
7.3.320.0000.00613.41
7.3.310.0000.00816.32
7.3.300.0040.00416.33
7.3.290.0030.01316.38
7.3.280.0060.01216.43
7.3.270.0130.00417.40
7.3.260.0100.00716.61
7.3.250.0140.00316.49
7.3.240.0000.01716.47
7.3.230.0070.01116.47
7.3.210.0090.00916.62
7.3.200.0090.01219.39
7.3.190.0160.00616.55
7.3.180.0130.00316.39
7.3.170.0160.00016.51
7.3.160.0100.01016.59
7.3.120.0000.01415.14
7.3.10.0120.01016.53
7.3.00.0160.00316.65
7.2.330.0060.01316.55
7.2.320.0060.01016.87
7.2.310.0090.00916.60
7.2.300.0030.01316.78
7.2.290.0030.01516.55
7.2.130.0150.00416.55
7.2.120.0140.00716.79
7.2.110.0100.00316.83
7.2.100.0050.00516.84
7.2.90.0060.00616.81
7.2.80.0030.00716.81
7.2.70.0060.00916.46
7.2.60.0060.00716.77
7.2.50.0230.00316.86
7.2.40.0110.00616.80
7.2.30.0110.01116.72
7.2.20.0030.00916.92
7.2.10.0090.00616.70
7.2.00.0070.00418.15
7.1.250.0140.00615.27
7.1.100.0030.01018.15
7.1.70.0050.00217.22
7.1.60.0140.01019.46
7.1.50.0060.01316.73
7.1.00.0030.07722.51
7.0.200.0000.00816.85
7.0.140.0070.07322.01
7.0.60.0170.08019.91
7.0.50.0030.05317.96
7.0.40.0100.04720.11
7.0.30.0270.03720.17
7.0.20.0370.07720.06
7.0.10.0070.05720.16
7.0.00.0130.08020.12
5.6.280.0070.06321.05
5.6.210.0170.05720.73
5.6.200.0100.08318.24
5.6.190.0130.08020.41
5.6.180.0300.07320.57
5.6.170.0270.07720.48
5.6.160.0070.04320.55
5.6.150.0170.06318.12
5.6.140.0030.04018.15
5.6.130.0100.07018.11
5.6.120.0100.08021.13
5.6.110.0070.04020.99
5.6.100.0030.09021.00
5.6.90.0070.08320.96
5.6.80.0030.04020.38
5.5.350.0230.08320.44
5.5.340.0070.05317.99
5.5.330.0000.05020.43
5.5.320.0070.07720.37
5.5.310.0130.04320.34
5.5.300.0100.07718.08
5.5.290.0030.08318.09
5.5.280.0000.06020.86
5.5.270.0130.05020.85
5.5.260.0070.05020.87
5.5.250.0230.07320.69
5.5.240.0130.07320.26
5.4.450.0170.05719.19
5.4.440.0770.05719.54
5.4.430.1300.06319.58
5.4.420.0870.05319.47
5.4.410.0900.06019.30
5.4.400.0770.08019.07
5.4.390.0830.06019.06
5.4.380.0230.05018.78
5.4.370.0170.05018.80
5.4.360.0100.05318.75
5.4.350.0030.06318.75
5.4.340.0230.04018.69
5.4.320.0080.03712.52
5.4.310.0030.04112.51
5.4.300.0030.04012.51
5.4.290.0080.04212.49
5.4.280.0010.04112.39
5.4.270.0060.04012.39
5.4.260.0140.06212.39
5.4.250.0110.05112.39
5.4.240.0050.04712.39
5.4.230.0080.04012.38
5.4.220.0100.03612.38
5.4.210.0160.07612.38
5.4.200.0130.06812.39
5.4.190.0100.09112.38
5.4.180.0090.07112.38
5.4.170.0100.07512.38
5.4.160.0230.08012.38
5.4.150.0120.06212.38
5.4.140.0130.07412.06
5.4.130.0190.05812.05
5.4.120.0140.06712.01
5.4.110.0150.06012.00
5.4.100.0160.12012.00
5.4.90.0100.07612.01
5.4.80.0140.04712.01
5.4.70.0140.05312.00
5.4.60.0090.04712.00
5.4.50.0090.04812.00
5.4.40.0060.04511.99
5.4.30.0040.03911.98
5.4.20.0070.04511.99
5.4.10.0170.08211.99
5.4.00.0080.05811.48
5.3.290.0100.04212.80
5.3.280.0080.05112.70
5.3.270.0130.05212.73
5.3.260.0090.05512.71
5.3.250.0070.05112.72
5.3.240.0100.05412.72
5.3.230.0050.04712.71
5.3.220.0080.04412.68
5.3.210.0100.05012.68
5.3.200.0210.05712.68
5.3.190.0190.06512.68
5.3.180.0270.06112.68
5.3.170.0130.07512.67
5.3.160.0140.06012.67
5.3.150.0150.09812.67
5.3.140.0120.06912.66
5.3.130.0120.05412.66
5.3.120.0110.05812.66
5.3.110.0120.05112.66
5.3.100.0050.04812.13
5.3.90.0130.06612.11
5.3.80.0110.03412.10
5.3.70.0080.04712.10
5.3.60.0070.05112.09
5.3.50.0100.03512.04
5.3.40.0070.03812.03
5.3.30.0100.04911.99
5.3.20.0080.03911.77
5.3.10.0110.04811.74
5.3.00.0050.03911.72
5.2.170.0050.0409.23
5.2.160.0060.0349.23
5.2.150.0070.0309.23
5.2.140.0060.0359.22
5.2.130.0190.0669.19
5.2.120.0230.0789.18
5.2.110.0080.0389.19
5.2.100.0160.0529.19
5.2.90.0060.0499.19
5.2.80.0050.0419.19
5.2.70.0060.0419.18
5.2.60.0100.0409.14
5.2.50.0030.0459.10
5.2.40.0150.0799.08
5.2.30.0070.0469.06
5.2.20.0090.0429.05
5.2.10.0060.0498.95
5.2.00.0090.0398.82
5.1.60.0050.0378.11
5.1.50.0090.0428.10
5.1.40.0080.0558.08
5.1.30.0120.0468.43
5.1.20.0110.0498.45
5.1.10.0080.0338.18
5.1.00.0080.0428.18
5.0.50.0090.0466.67
5.0.40.0150.0846.52
5.0.30.0160.0606.34
5.0.20.0220.0566.30
5.0.10.0080.0526.28
5.0.00.0090.0376.28
4.4.90.0050.0234.78
4.4.80.0030.0224.75
4.4.70.0030.0174.75
4.4.60.0030.0174.75
4.4.50.0060.0164.77
4.4.40.0060.0314.71
4.4.30.0140.0374.75
4.4.20.0080.0504.84
4.4.10.0070.0144.85
4.4.00.0030.0364.76
4.3.110.0060.0214.66
4.3.100.0050.0254.67
4.3.90.0090.0294.63
4.3.80.0160.0514.58
4.3.70.0040.0164.63
4.3.60.0020.0164.63
4.3.50.0010.0214.63
4.3.40.0040.0324.54
4.3.30.0070.0213.30
4.3.20.0020.0243.28
4.3.10.0060.0203.23
4.3.00.0100.01316.03

preferences:
39.84 ms | 400 KiB | 5 Q