3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Sqltree { private $FlatTable, $paths; public function __construct($FlatTable) { $this->FlatTable = $FlatTable; } public function generateTable($tree) { $this->paths = array(); $this->path_recursion($tree, array()); print_r($paths); } private function path_recursion($tree, $parents) { //Path erzeugen $this->paths[] = array($tree, $tree, 0); foreach($parents as $parent) { $this->paths[] = array($parent['id'], $tree['id'], $parents['path_length']); $parents['path_length']++; } if(is_array($tree['children'])) { $parents = array('id' => $tree['id'], 'path_length' => 1); foreach($tree['children'] as $child) { $this->path_recursion($child, $parents); } } } public static function CreateTable($FlatTable) { $sql = "CREATE TABLE ClosureTable ( ancestor_id INT NOT NULL REFERENCES $FlatTable(id), descendant_id INT NOT NULL REFERENCES $FlatTable(id), path_length INT, PRIMARY KEY (ancestor_id, descendant_id) );"; sql::create($sql); } } $tree = array(array('id' => 1, 'children' => array(array('id' => 2, 'children' => array('id' => 4, 'children' => false)), array('id' => 3, 'children' => false)))); print_r($tree); $sqltree = new SqlTree('asd'); $sqltree->generateTable($tree); ?>

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.0170.00318.55
8.3.50.0120.00522.05
8.3.40.0040.01118.79
8.3.30.0170.00018.88
8.3.20.0090.00918.80
8.3.10.0040.01120.67
8.3.00.0070.01123.65
8.2.180.0160.00616.63
8.2.170.0130.00322.96
8.2.160.0070.00720.35
8.2.150.0160.00324.18
8.2.140.0040.00424.66
8.2.130.0170.00026.16
8.2.120.0060.00319.38
8.2.110.0070.00321.03
8.2.100.0110.00317.97
8.2.90.0000.00819.03
8.2.80.0050.00318.03
8.2.70.0000.00817.50
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0050.00318.34
8.2.30.0000.00719.79
8.2.20.0070.00017.79
8.2.10.0040.00417.70
8.2.00.0000.00817.82
8.1.280.0120.00625.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0030.00528.09
8.1.240.0060.00322.64
8.1.230.0110.00020.92
8.1.220.0050.00318.77
8.1.210.0030.00618.92
8.1.200.0060.00317.35
8.1.190.0060.00317.66
8.1.180.0000.00718.10
8.1.170.0030.00618.53
8.1.160.0040.00418.91
8.1.150.0070.00018.71
8.1.140.0080.00017.42
8.1.130.0030.00317.89
8.1.120.0040.00417.48
8.1.110.0000.00817.50
8.1.100.0040.00417.48
8.1.90.0040.00417.50
8.1.80.0000.00717.48
8.1.70.0030.00317.43
8.1.60.0030.00617.46
8.1.50.0030.00617.36
8.1.40.0040.00417.55
8.1.30.0050.00317.49
8.1.20.0000.00817.57
8.1.10.0040.00417.56
8.1.00.0080.00017.41
8.0.300.0040.00419.98
8.0.290.0000.01016.63
8.0.280.0000.00718.39
8.0.270.0000.00717.21
8.0.260.0030.00316.91
8.0.250.0040.00417.12
8.0.240.0030.00716.95
8.0.230.0080.00017.02
8.0.220.0000.00716.84
8.0.210.0050.00316.94
8.0.200.0030.00316.89
8.0.190.0080.00017.02
8.0.180.0040.00416.97
8.0.170.0000.00816.98
8.0.160.0040.00416.97
8.0.150.0000.00816.80
8.0.140.0040.00716.73
8.0.130.0030.00613.42
8.0.120.0000.00816.93
8.0.110.0000.00716.77
8.0.100.0040.00416.99
8.0.90.0000.00716.82
8.0.80.0060.00817.01
8.0.70.0040.00417.09
8.0.60.0000.00816.93
8.0.50.0080.00016.96
8.0.30.0090.00917.14
8.0.20.0110.00717.40
8.0.10.0040.00417.05
8.0.00.0120.00716.94
7.4.330.0000.00513.43
7.4.320.0000.00716.73
7.4.300.0030.00316.62
7.4.290.0070.00016.55
7.4.280.0040.00416.57
7.4.270.0030.00316.46
7.4.260.0030.00313.31
7.4.250.0000.00816.65
7.4.240.0070.00016.45
7.4.230.0000.00816.53
7.4.220.0110.00616.71
7.4.210.0100.00716.58
7.4.200.0070.00016.68
7.4.190.0000.00716.73
7.4.160.0180.00016.70
7.4.150.0200.00417.40
7.4.140.0130.00517.86
7.4.130.0120.00816.62
7.4.120.0080.00816.51
7.4.110.0100.00716.45
7.4.100.0090.00816.56
7.4.90.0140.00316.52
7.4.80.0060.01219.37
7.4.70.0030.01316.48
7.4.60.0080.00816.32
7.4.50.0030.00616.84
7.4.40.0040.01122.27
7.4.30.0040.01316.50
7.4.10.0030.01615.27
7.4.00.0050.00515.08
7.3.330.0030.00313.32
7.3.320.0060.00013.44
7.3.310.0000.00716.36
7.3.300.0030.00316.40
7.3.290.0040.01116.36
7.3.280.0080.01216.38
7.3.270.0060.00917.40
7.3.260.0090.01118.24
7.3.250.0110.01116.52
7.3.240.0170.00316.63
7.3.230.0110.00716.57
7.3.210.0180.00616.65
7.3.200.0040.01219.39
7.3.190.0070.01016.54
7.3.180.0070.01116.73
7.3.170.0130.00316.45
7.3.160.0090.00616.38
7.3.130.0030.01414.63
7.3.120.0100.00714.97
7.3.110.0100.01014.80
7.3.100.0090.00915.10
7.3.90.0060.00914.77
7.3.80.0000.01714.65
7.3.70.0090.00614.59
7.3.60.0090.00914.84
7.3.50.0110.00814.73
7.3.40.0080.00614.93
7.3.30.0040.00414.84
7.3.20.0000.01316.79
7.3.10.0080.00916.69
7.3.00.0110.00716.60
7.2.330.0090.00916.53
7.2.320.0040.01516.74
7.2.310.0000.01916.82
7.2.300.0110.00816.42
7.2.290.0070.01016.91
7.2.260.0090.00915.18
7.2.250.0090.01215.20
7.2.240.0070.00715.07
7.2.230.0120.00314.78
7.2.220.0090.00615.34
7.2.210.0050.00514.95
7.2.200.0030.00915.25
7.2.190.0100.00715.11
7.2.180.0000.01015.05
7.2.170.0040.00815.19
7.2.160.0070.00715.13
7.2.150.0100.00316.95
7.2.140.0030.00717.05
7.2.130.0120.00216.89
7.2.120.0050.01416.91
7.2.110.0110.00116.82
7.2.100.0110.00516.87
7.2.90.0060.00716.92
7.2.80.0070.00716.86
7.2.70.0070.00516.60
7.2.60.0130.00216.95
7.2.50.0100.00216.80
7.2.40.0060.00716.80
7.2.30.0110.00716.99
7.2.20.0050.00817.00
7.2.10.0070.00816.70
7.2.00.0030.01017.85
7.1.330.0040.01115.76
7.1.320.0090.00615.94
7.1.310.0060.00615.52
7.1.300.0030.01315.78
7.1.290.0140.00015.59
7.1.280.0000.01115.92
7.1.270.0040.01215.76
7.1.260.0030.01015.86
7.1.250.0060.01015.73
7.1.240.0040.01115.82
7.1.230.0060.00315.72
7.1.220.0080.00015.55
7.1.210.0030.00915.60
7.1.200.0060.00615.92
7.1.190.0030.00615.93
7.1.180.0070.01015.59
7.1.170.0070.00316.02
7.1.160.0070.00415.76
7.1.150.0030.01015.96
7.1.140.0090.00615.83
7.1.130.0070.01015.60
7.1.120.0000.00815.77
7.1.110.0100.00615.56
7.1.100.0000.01316.82
7.1.90.0090.00915.94
7.1.80.0070.00415.73
7.1.70.0040.00616.41
7.1.60.0060.01117.57
7.1.50.0080.00616.53
7.1.40.0000.01215.74
7.1.30.0060.00315.82
7.1.20.0040.00815.46
7.1.10.0080.00415.80
7.1.00.0030.02319.11
7.0.330.0060.00615.40
7.0.320.0090.00315.44
7.0.310.0030.00615.45
7.0.300.0040.01115.48
7.0.290.0060.00615.27
7.0.280.0140.00315.59
7.0.270.0000.01515.48
7.0.260.0080.00815.62
7.0.250.0070.01015.31
7.0.240.0060.01215.46
7.0.230.0100.00715.50
7.0.220.0060.00915.34
7.0.210.0070.01015.30
7.0.200.0400.00615.11
7.0.190.0080.00415.59
7.0.180.0120.00315.47
7.0.170.0100.00315.31
7.0.160.0110.00015.51
7.0.150.0040.01215.57
7.0.140.0100.03518.73
7.0.130.0000.01315.50
7.0.120.0160.00015.70
7.0.110.0100.00315.59
7.0.100.0100.00715.42
7.0.90.0100.00315.27
7.0.80.0060.00615.21
7.0.70.0080.04318.58
7.0.60.0060.04518.57
7.0.50.0090.04318.88
7.0.40.0050.04716.85
7.0.30.0030.04316.66
7.0.20.0020.03416.76
7.0.10.0090.04216.74
7.0.00.0080.04216.79
5.6.400.0040.00914.29
5.6.390.0030.01414.79
5.6.380.0060.00614.75
5.6.370.0080.00314.29
5.6.360.0030.00614.52
5.6.350.0030.00714.47
5.6.340.0130.00614.40
5.6.330.0000.01314.32
5.6.320.0100.00714.54
5.6.310.0060.01014.03
5.6.300.0070.01014.63
5.6.290.0060.00614.53
5.6.280.0050.05217.80
5.6.270.0070.00714.35
5.6.260.0080.00614.82
5.6.250.0000.01914.30
5.6.240.0040.01214.68
5.6.230.0040.00814.40
5.6.220.0070.03617.45
5.6.210.0030.03817.72
5.6.200.0060.05017.94
5.6.190.0050.04717.85
5.6.180.0080.03917.70
5.6.170.0050.03317.72
5.6.160.0020.04517.93
5.6.150.0070.03417.89
5.6.140.0100.04317.70
5.6.130.0030.04517.65
5.6.120.0090.04517.76
5.6.110.0070.03317.79
5.6.100.0050.03017.84
5.6.90.0040.03717.88
5.6.80.0050.03417.38
5.6.70.0080.04017.40
5.6.60.0050.03517.43
5.6.50.0020.04617.46
5.6.40.0030.04517.45
5.6.30.0060.04417.45
5.6.20.0060.03017.44
5.6.10.0070.02817.26
5.6.00.0050.04117.34
5.5.380.0040.00814.25
5.5.370.0080.00414.57
5.5.360.0040.04517.37
5.5.350.0020.03917.28
5.5.340.0050.04717.57
5.5.330.0080.03817.55
5.5.320.0090.02617.55
5.5.310.0080.04417.66
5.5.300.0110.04217.64
5.5.290.0020.03017.59
5.5.280.0100.04317.61
5.5.270.0050.04917.44
5.5.260.0020.04817.46
5.5.250.0050.04417.49
5.5.240.0050.03817.18
5.5.230.0060.04617.29
5.5.220.0000.04417.36
5.5.210.0050.03817.24
5.5.200.0060.02517.15
5.5.190.0050.04317.26
5.5.180.0030.03717.34
5.5.170.0060.00914.37
5.5.160.0020.04817.23
5.5.150.0040.02717.11
5.5.140.0060.03317.23
5.5.130.0050.03017.18
5.5.120.0080.03817.15
5.5.110.0030.04217.28
5.5.100.0070.03717.14
5.5.90.0030.04317.27
5.5.80.0130.03517.20
5.5.70.0050.03517.05
5.5.60.0050.04217.11
5.5.50.0020.04817.06
5.5.40.0060.04117.11
5.5.30.0030.03017.08
5.5.20.0090.04116.97
5.5.10.0030.03517.18
5.5.00.0070.03816.93
5.4.450.0050.04515.28
5.4.440.0050.04315.30
5.4.430.0060.03815.27
5.4.420.0070.04215.16
5.4.410.0020.04515.44
5.4.400.0030.04315.10
5.4.390.0020.04315.22
5.4.380.0060.02915.08
5.4.370.0080.03515.03
5.4.360.0060.04015.19
5.4.350.0020.04215.09
5.4.340.0020.04715.11
5.4.330.0000.00711.27
5.4.320.0030.02615.11
5.4.310.0070.03714.95
5.4.300.0050.03315.00
5.4.290.0030.04215.08
5.4.280.0050.03015.16
5.4.270.0020.03515.05
5.4.260.0070.04315.10
5.4.250.0070.04215.14
5.4.240.0050.03715.21
5.4.230.0040.03715.21
5.4.220.0030.04315.05
5.4.210.0020.04414.93
5.4.200.0050.03915.08
5.4.190.0000.04414.99
5.4.180.0050.04115.13
5.4.170.0090.03714.98
5.4.160.0030.04315.09
5.4.150.0000.02815.01
5.4.140.0060.01813.77
5.4.130.0020.02913.59
5.4.120.0040.03613.82
5.4.110.0050.02313.74
5.4.100.0020.02513.82
5.4.90.0060.03513.76
5.4.80.0030.04113.71
5.4.70.0020.04213.78
5.4.60.0030.04013.72
5.4.50.0020.04213.72
5.4.40.0050.04013.79
5.4.30.0020.03513.65
5.4.20.0030.04313.85
5.4.10.0030.04113.82
5.4.00.0030.04213.53
5.3.290.0030.03112.65
5.3.280.0020.04512.67
5.3.270.0030.03612.72
5.3.260.0060.04012.71
5.3.250.0020.02912.72
5.3.240.0030.02712.64
5.3.230.0020.04512.59
5.3.220.0030.03712.55
5.3.210.0030.02112.70
5.3.200.0050.01912.70
5.3.190.0020.02312.71
5.3.180.0030.02712.69
5.3.170.0020.04312.70
5.3.160.0010.04112.69
5.3.150.0030.04212.73
5.3.140.0050.03912.75
5.3.130.0060.03812.60
5.3.120.0020.04712.65
5.3.110.0020.04012.72
5.3.100.0100.03612.36
5.3.90.0050.03812.45
5.3.80.0050.03712.29
5.3.70.0010.04112.27
5.3.60.0040.04112.23
5.3.50.0040.03812.34
5.3.40.0050.03512.36
5.3.30.0030.04212.33
5.3.20.0020.03012.20
5.3.10.0030.04112.03
5.3.00.0060.03611.96
5.2.170.0030.04311.20
5.2.160.0000.06311.14
5.2.150.0000.04011.19
5.2.140.0030.06711.04
5.2.130.0070.06011.22
5.2.120.0030.05011.17
5.2.110.0030.05711.23
5.2.100.0000.06311.14
5.2.90.0000.07011.23
5.2.80.0030.06011.16
5.2.70.0030.05711.14
5.2.60.0000.04311.20
5.2.50.0000.06711.12
5.2.40.0070.05711.07
5.2.30.0070.06010.91
5.2.20.0030.06310.83
5.2.10.0070.05711.02
5.2.00.0070.05710.66
5.1.60.0030.03310.27
5.1.50.0030.04710.27
5.1.40.0000.04010.27
5.1.30.0030.05710.27
5.1.20.0070.05010.28
5.1.10.0030.04310.27
5.1.00.0070.05710.27
5.0.50.0030.03710.27
5.0.40.0000.04310.27
5.0.30.0030.06710.27
5.0.20.0100.03710.27
5.0.10.0000.03710.27
5.0.00.0000.06710.27
4.4.90.0070.02310.27
4.4.80.0070.02010.27
4.4.70.0030.03310.27
4.4.60.0030.03010.27
4.4.50.0030.03310.27
4.4.40.0000.05710.27
4.4.30.0000.02310.27
4.4.20.0000.03710.27
4.4.10.0000.03310.27
4.4.00.0030.05310.27
4.3.110.0000.04010.27
4.3.100.0070.02310.27
4.3.90.0000.03010.27
4.3.80.0000.03710.27
4.3.70.0000.03310.27
4.3.60.0000.02710.27
4.3.50.0000.03710.27
4.3.40.0000.05310.27
4.3.30.0030.03310.27
4.3.20.0000.03710.27
4.3.10.0030.03310.27
4.3.00.0030.03310.27

preferences:
48.13 ms | 401 KiB | 5 Q