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); echo($ans); ?>

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.0040.01116.86
8.3.50.0140.00522.04
8.3.40.0150.00618.84
8.3.30.0030.01019.26
8.3.20.0080.00020.07
8.3.10.0060.00323.65
8.3.00.0090.00019.51
8.2.180.0090.00618.40
8.2.170.0110.01122.96
8.2.160.0090.00620.43
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0110.00726.16
8.2.120.0000.00722.26
8.2.110.0080.00022.25
8.2.100.0130.00017.91
8.2.90.0000.00819.06
8.2.80.0000.00817.97
8.2.70.0040.00417.75
8.2.60.0020.00917.80
8.2.50.0040.00418.07
8.2.40.0050.00319.88
8.2.30.0000.00818.13
8.2.20.0030.00517.77
8.2.10.0000.00718.13
8.2.00.0040.00417.64
8.1.280.0130.00725.92
8.1.270.0000.00923.84
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0100.00023.81
8.1.230.0070.00319.23
8.1.220.0080.00017.75
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0050.00217.66
8.1.180.0000.00818.10
8.1.170.0080.00018.71
8.1.160.0080.00021.91
8.1.150.0070.00318.68
8.1.140.0040.00417.35
8.1.130.0030.00317.84
8.1.120.0000.00717.51
8.1.110.0040.00417.46
8.1.100.0040.00417.45
8.1.90.0070.00017.50
8.1.80.0040.00417.48
8.1.70.0030.00317.38
8.1.60.0000.00917.51
8.1.50.0030.00517.51
8.1.40.0050.00217.59
8.1.30.0000.00817.54
8.1.20.0070.00017.55
8.1.10.0040.00417.58
8.1.00.0050.00317.53
8.0.300.0050.00219.09
8.0.290.0030.00617.04
8.0.280.0070.00018.52
8.0.270.0000.00717.28
8.0.260.0050.00317.29
8.0.250.0040.00417.00
8.0.240.0030.00317.04
8.0.230.0030.00316.90
8.0.220.0040.00417.05
8.0.210.0000.00716.98
8.0.200.0030.00317.03
8.0.190.0050.00317.08
8.0.180.0040.00417.02
8.0.170.0040.00417.05
8.0.160.0000.00716.85
8.0.150.0080.00017.03
8.0.140.0070.00016.84
8.0.130.0000.00513.45
8.0.120.0000.00816.91
8.0.110.0050.00316.80
8.0.100.0040.00416.87
8.0.90.0020.00516.77
8.0.80.0100.00716.98
8.0.70.0050.00316.88
8.0.60.0000.00716.84
8.0.50.0040.00416.80
8.0.30.0100.01317.20
8.0.20.0170.00117.40
8.0.10.0000.00817.05
8.0.00.0070.01116.67
7.4.330.0000.00515.03
7.4.320.0000.00616.60
7.4.300.0000.00616.51
7.4.290.0000.00716.68
7.4.280.0050.00216.62
7.4.270.0070.00016.59
7.4.260.0050.00216.59
7.4.250.0030.00516.60
7.4.240.0000.00716.50
7.4.230.0040.00416.63
7.4.220.0090.00916.58
7.4.210.0080.00616.67
7.4.200.0030.00316.63
7.4.190.0000.00716.77
7.4.160.0060.00916.58
7.4.150.0130.00617.40
7.4.140.0080.01217.86
7.4.130.0100.00816.58
7.4.120.0070.01116.60
7.4.110.0100.01316.36
7.4.100.0090.01216.64
7.4.90.0030.01316.75
7.4.80.0080.01219.39
7.4.70.0080.00916.48
7.4.60.0100.00616.48
7.4.50.0060.00316.66
7.4.40.0150.00916.37
7.4.30.0100.00716.75
7.4.00.0040.01415.13
7.3.330.0040.00413.41
7.3.320.0030.00313.24
7.3.310.0000.00716.29
7.3.300.0000.00716.46
7.3.290.0090.00616.45
7.3.280.0110.01016.43
7.3.270.0110.00617.40
7.3.260.0100.00716.39
7.3.250.0090.00816.50
7.3.240.0030.01216.62
7.3.230.0130.00516.39
7.3.210.0090.00616.38
7.3.200.0060.01519.39
7.3.190.0120.00616.59
7.3.180.0060.01116.50
7.3.170.0070.01016.63
7.3.160.0060.01016.53
7.3.120.0070.01014.86
7.2.330.0060.01216.68
7.2.320.0110.00716.81
7.2.310.0090.00916.79
7.2.300.0030.01416.71
7.2.290.0070.01016.84
7.2.80.0030.00916.63
7.2.60.0070.00717.04
7.2.00.0060.00619.51
7.1.200.0070.00715.72
7.1.100.0030.01017.95
7.1.70.0060.00317.37
7.1.60.0070.01719.46
7.1.50.0100.01316.91
7.1.00.0030.07722.48
7.0.200.0000.00716.85
7.0.140.0100.09021.91
7.0.60.0100.08019.84
7.0.50.0030.04017.89
7.0.40.0100.08320.35
7.0.30.0230.05020.23
7.0.20.0300.07320.21
7.0.10.0130.05020.34
7.0.00.0000.09020.07
5.6.280.0100.06720.82
5.6.210.0000.04320.47
5.6.200.0130.04718.18
5.6.190.0170.06720.61
5.6.180.0100.05020.68
5.6.170.0200.05720.62
5.6.160.0000.05020.57
5.6.150.0070.03718.19
5.6.140.0030.06718.12
5.6.130.0130.07318.14
5.6.120.0100.07021.00
5.6.110.0100.08720.89
5.6.100.0200.07020.99
5.6.90.0030.06321.04
5.6.80.0100.05720.39
5.5.350.3870.04020.48
5.5.340.0000.04317.98
5.5.330.0030.08020.42
5.5.320.0330.03320.34
5.5.310.0370.03320.25
5.5.300.0100.04017.94
5.5.290.0070.06718.02
5.5.280.0000.04320.89
5.5.270.0100.05320.77
5.5.260.0070.05320.65
5.5.250.0030.05720.51
5.5.240.0000.06020.36
5.4.450.0230.06719.17
5.4.440.0200.05319.45
5.4.430.0230.04719.48
5.4.420.0130.05319.33
5.4.410.0100.06019.25
5.4.400.0170.05019.02
5.4.390.0300.04019.26
5.4.380.0100.05718.59
5.4.370.0130.05018.73
5.4.360.0100.05018.79
5.4.350.0070.05318.61
5.4.340.0000.06018.77
5.4.320.0040.03812.51
5.4.310.0050.04112.50
5.4.300.0090.04112.51
5.4.290.0090.03912.49
5.4.280.0070.03612.39
5.4.270.0060.03812.39
5.4.260.0090.03712.39
5.4.250.0060.04212.39
5.4.240.0060.04612.39
5.4.230.0110.08412.38
5.4.220.0120.08912.38
5.4.210.0080.05112.38
5.4.200.0090.05512.38
5.4.190.0160.06312.38
5.4.180.0220.08512.38
5.4.170.0070.05012.38
5.4.160.0130.05712.38
5.4.150.0140.07712.38
5.4.140.0150.08512.06
5.4.130.0120.07212.05
5.4.120.0060.07412.01
5.4.110.0060.06112.01
5.4.100.0130.06712.01
5.4.90.0150.06512.00
5.4.80.0080.05512.00
5.4.70.0130.04912.00
5.4.60.0090.05412.00
5.4.50.0110.07912.00
5.4.40.0130.05211.99
5.4.30.0050.04011.98
5.4.20.0040.03911.99
5.4.10.0060.03611.98
5.4.00.0030.04011.48
5.3.290.0040.04112.80
5.3.280.0060.04312.71
5.3.270.0070.04712.72
5.3.260.0070.05412.72
5.3.250.0090.05412.72
5.3.240.0060.06512.72
5.3.230.0100.05212.71
5.3.220.0140.05212.68
5.3.210.0230.10812.68
5.3.200.0110.07712.68
5.3.190.0140.05112.68
5.3.180.0090.05012.67
5.3.170.0120.06112.67
5.3.160.0110.05112.67
5.3.150.0060.07512.67
5.3.140.0120.06612.66
5.3.130.0150.06512.66
5.3.120.0110.03812.66
5.3.110.0090.04912.65
5.3.100.0310.08712.13
5.3.90.0190.10212.11
5.3.80.0110.03812.10
5.3.70.0090.06312.10
5.3.60.0080.05712.09
5.3.50.0110.05512.03
5.3.40.0070.04612.04
5.3.30.0080.03911.99
5.3.20.0120.07111.77
5.3.10.0130.04611.74
5.3.00.0160.06111.73
5.2.170.0070.0479.23
5.2.160.0080.0469.23
5.2.150.0080.0559.23
5.2.140.0110.0389.22
5.2.130.0040.0449.18
5.2.120.0090.0399.18
5.2.110.0070.0509.19
5.2.100.0060.0449.18
5.2.90.0040.0449.19
5.2.80.0120.0719.19
5.2.70.0080.0569.18
5.2.60.0080.0509.14
5.2.50.0120.0559.10
5.2.40.0190.0889.08
5.2.30.0150.0789.06
5.2.20.0120.0529.05
5.2.10.0050.0348.95
5.2.00.0060.0308.82
5.1.60.0070.0248.11
5.1.50.0040.0268.10
5.1.40.0050.0258.08
5.1.30.0060.0258.43
5.1.20.0030.0298.45
5.1.10.0050.0298.18
5.1.00.0050.0278.18
5.0.50.0030.0346.66
5.0.40.0050.0226.52
5.0.30.0040.0326.34
5.0.20.0040.0226.30
5.0.10.0040.0236.28
5.0.00.0010.0336.28
4.4.90.0040.0154.78
4.4.80.0030.0204.75
4.4.70.0070.0224.75
4.4.60.0080.0424.76
4.4.50.0030.0194.77
4.4.40.0030.0354.71
4.4.30.0040.0214.76
4.4.20.0060.0214.84
4.4.10.0020.0254.85
4.4.00.0030.0324.76
4.3.110.0060.0194.67
4.3.100.0040.0214.67
4.3.90.0040.0184.63
4.3.80.0030.0284.59
4.3.70.0060.0254.63
4.3.60.0030.0214.63
4.3.50.0060.0204.63
4.3.40.0030.0314.54
4.3.30.0000.0233.30
4.3.20.0070.0173.28
4.3.10.0040.0183.23
4.3.00.0030.0207.27

preferences:
64.68 ms | 400 KiB | 5 Q