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($this->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('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.0110.00418.43
8.3.50.0120.00321.27
8.3.40.0100.01018.79
8.3.30.0060.01618.71
8.3.20.0000.00818.79
8.3.10.0000.00820.48
8.3.00.0040.00421.82
8.2.180.0100.01018.25
8.2.170.0110.00422.96
8.2.160.0070.00720.41
8.2.150.0090.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0050.00319.24
8.2.110.0040.00720.88
8.2.100.0060.00617.91
8.2.90.0040.00419.19
8.2.80.0040.00418.05
8.2.70.0120.00017.50
8.2.60.0050.00317.93
8.2.50.0080.00018.07
8.2.40.0100.00317.96
8.2.30.0040.00419.91
8.2.20.0080.00017.81
8.2.10.0060.00317.75
8.2.00.0040.00417.75
8.1.280.0040.01125.92
8.1.270.0090.00623.99
8.1.260.0060.01226.35
8.1.250.0060.00328.09
8.1.240.0090.00022.65
8.1.230.0090.00320.95
8.1.220.0040.00418.77
8.1.210.0030.00618.88
8.1.200.0060.00317.38
8.1.190.0040.00417.53
8.1.180.0030.00518.10
8.1.170.0030.00518.35
8.1.160.0060.00319.00
8.1.150.0020.00518.69
8.1.140.0030.00517.37
8.1.130.0040.00417.84
8.1.120.0040.00417.39
8.1.110.0000.00817.33
8.1.100.0030.00517.51
8.1.90.0080.00017.47
8.1.80.0000.00717.54
8.1.70.0000.00717.48
8.1.60.0030.00617.60
8.1.50.0050.00317.52
8.1.40.0040.00417.43
8.1.30.0040.00417.64
8.1.20.0000.00917.56
8.1.10.0050.00317.46
8.1.00.0080.00017.60
8.0.300.0000.00820.03
8.0.290.0030.00516.75
8.0.280.0030.00318.38
8.0.270.0000.00717.28
8.0.260.0030.00316.74
8.0.250.0000.01117.04
8.0.240.0000.00816.93
8.0.230.0070.00017.05
8.0.220.0030.00316.97
8.0.210.0070.00016.99
8.0.200.0070.00017.07
8.0.190.0040.00416.94
8.0.180.0000.00716.89
8.0.170.0040.00417.01
8.0.160.0040.00416.95
8.0.150.0000.00916.90
8.0.140.0030.00516.84
8.0.130.0060.00313.35
8.0.120.0050.00316.91
8.0.110.0000.00816.85
8.0.100.0040.00416.93
8.0.90.0000.00816.99
8.0.80.0060.00917.00
8.0.70.0050.00216.80
8.0.60.0000.00816.85
8.0.50.0030.00516.82
8.0.30.0130.01017.12
8.0.20.0080.01017.40
8.0.10.0000.00717.12
8.0.00.0080.01116.85
7.4.330.0050.00014.73
7.4.320.0040.00416.65
7.4.300.0030.00316.64
7.4.290.0050.00216.63
7.4.280.0050.00316.46
7.4.270.0000.00716.56
7.4.260.0000.00613.31
7.4.250.0070.00016.40
7.4.240.0000.00716.56
7.4.230.0070.00016.71
7.4.220.0100.01416.51
7.4.210.0110.00416.58
7.4.200.0000.00816.35
7.4.190.0040.00416.68
7.4.160.0100.00716.69
7.4.150.0190.00617.40
7.4.140.0070.01517.86
7.4.130.0100.00716.63
7.4.120.0100.00816.62
7.4.110.0100.01016.68
7.4.100.0070.01116.55
7.4.90.0080.01116.73
7.4.80.0100.00719.37
7.4.70.0070.01116.68
7.4.60.0060.00916.64
7.4.50.0000.00916.70
7.4.40.0030.01222.27
7.4.30.0090.01216.48
7.4.00.0070.01115.12
7.3.330.0000.00513.21
7.3.320.0000.00613.30
7.3.310.0070.00016.35
7.3.300.0000.00716.38
7.3.290.0070.00716.36
7.3.280.0100.00816.38
7.3.270.0110.00617.40
7.3.260.0120.00818.24
7.3.250.0100.00916.43
7.3.240.0130.00416.31
7.3.230.0060.01016.47
7.3.210.0160.00016.62
7.3.200.0170.00019.39
7.3.190.0090.01316.70
7.3.180.0110.00516.62
7.3.170.0030.01616.51
7.3.160.0080.00816.40
7.3.120.0080.00814.96
7.3.110.0030.01014.71
7.3.100.0070.01114.57
7.3.90.0040.01114.75
7.3.80.0060.00314.60
7.3.70.0030.01014.93
7.3.60.0070.00715.00
7.3.50.0030.00614.62
7.3.40.0070.00714.86
7.3.30.0030.00714.79
7.3.20.0120.00616.52
7.3.10.0030.01016.71
7.3.00.0000.01416.57
7.2.330.0040.01316.72
7.2.320.0070.01016.59
7.2.310.0060.01416.78
7.2.300.0070.01116.91
7.2.290.0030.01316.86
7.2.250.0030.01415.13
7.2.240.0000.01815.16
7.2.230.0100.00614.92
7.2.220.0040.00814.85
7.2.210.0110.00314.70
7.2.200.0030.01315.10
7.2.190.0070.00714.79
7.2.180.0090.00315.02
7.2.170.0090.00615.22
7.2.160.0000.01614.85
7.2.150.0030.01216.96
7.2.140.0070.00716.85
7.2.130.0090.00616.98
7.2.120.0120.00416.95
7.2.110.0030.01416.79
7.2.100.0070.00716.93
7.2.90.0060.01016.88
7.2.80.0090.00616.90
7.2.70.0120.00616.66
7.2.60.0120.00917.04
7.2.50.0090.00316.79
7.2.40.0070.01016.65
7.2.30.0040.01117.07
7.2.20.0030.00716.91
7.2.10.0070.01116.78
7.2.00.0020.01418.25
7.1.330.0070.01015.85
7.1.320.0070.00715.80
7.1.310.0000.00915.95
7.1.300.0030.00615.73
7.1.290.0060.00315.55
7.1.280.0070.00715.80
7.1.270.0030.01315.77
7.1.260.0000.01415.67
7.1.250.0000.01415.77
7.1.240.0070.01015.78
7.1.230.0100.00315.68
7.1.220.0130.00315.74
7.1.210.0060.00615.59
7.1.200.0060.01015.52
7.1.190.0030.01215.93
7.1.180.0070.00715.80
7.1.170.0070.00415.78
7.1.160.0090.00615.75
7.1.150.0070.00715.99
7.1.140.0070.00415.71
7.1.130.0040.01115.70
7.1.120.0040.00915.80
7.1.110.0080.00415.95
7.1.100.0070.00816.81
7.1.90.0000.01315.49
7.1.80.0090.00315.76
7.1.70.0050.00516.54
7.1.60.0100.00817.47
7.1.50.0100.00516.52
7.1.40.0040.00415.77
7.1.30.0110.00015.88
7.1.20.0080.00315.77
7.1.10.0040.00815.43
7.1.00.0030.04019.09
7.0.330.0060.00914.91
7.0.320.0100.00715.43
7.0.310.0150.00715.18
7.0.300.0090.00615.23
7.0.290.0120.00915.20
7.0.280.0130.01015.00
7.0.270.0030.01415.43
7.0.260.0100.01415.07
7.0.250.0100.00715.20
7.0.240.0140.01015.37
7.0.230.0060.01215.51
7.0.220.0070.00715.23
7.0.210.0040.01215.40
7.0.200.0180.00815.20
7.0.190.0060.01315.16
7.0.180.0070.01515.04
7.0.170.0070.00715.27
7.0.160.0120.00615.51
7.0.150.0070.00715.33
7.0.140.0100.03318.81
7.0.130.0100.01015.39
7.0.120.0080.00815.13
7.0.110.0070.00715.07
7.0.100.0030.01915.40
7.0.90.0200.00015.48
7.0.80.0100.01015.38
7.0.70.0150.04218.42
7.0.60.0050.05018.57
7.0.50.0070.04318.72
7.0.40.0050.05116.62
7.0.30.0130.04416.81
7.0.20.0060.03416.80
7.0.10.0120.04216.76
7.0.00.0060.04916.76
5.6.400.0080.01114.28
5.6.390.0150.00014.30
5.6.380.0100.00314.49
5.6.370.0070.01813.96
5.6.360.0030.01314.45
5.6.350.0030.01514.42
5.6.340.0110.01414.36
5.6.330.0060.01214.37
5.6.320.0030.01614.18
5.6.310.0100.00714.45
5.6.300.0060.00914.28
5.6.290.0030.01614.43
5.6.280.0050.04117.72
5.6.270.0100.00614.48
5.6.260.0030.01414.75
5.6.250.0090.01214.04
5.6.240.0090.00614.15
5.6.230.0030.01714.22
5.6.220.0090.03717.39
5.6.210.0090.04617.45
5.6.200.0080.04317.59
5.6.190.0080.04717.79
5.6.180.0110.04117.81
5.6.170.0090.03617.78
5.6.160.0100.04117.76
5.6.150.0070.04817.77
5.6.140.0090.04717.70
5.6.130.0080.04517.62
5.6.120.0080.04817.76
5.6.110.0120.04917.64
5.6.100.0100.04517.57
5.6.90.0030.04617.71
5.6.80.0030.04317.46
5.6.70.0070.03117.25
5.6.60.0070.04917.29
5.6.50.0070.02517.31
5.6.40.0080.02317.47
5.6.30.0020.02917.58
5.6.20.0050.02617.38
5.6.10.0080.03117.43
5.6.00.0080.02317.38
5.5.380.0080.00414.59
5.5.370.0100.01014.46
5.5.360.0110.04517.38
5.5.350.0090.04817.10
5.5.340.0070.04417.44
5.5.330.0080.04617.52
5.5.320.0050.04917.51
5.5.310.0230.03217.70
5.5.300.0120.04417.51
5.5.290.0130.03517.53
5.5.280.0160.04017.56
5.5.270.0090.05217.66
5.5.260.0080.05017.46
5.5.250.0070.04717.49
5.5.240.0100.02517.24
5.5.230.0150.03917.21
5.5.220.0060.05017.16
5.5.210.0100.04317.20
5.5.200.0020.02917.31
5.5.190.0030.02617.12
5.5.180.0080.02317.40
5.5.170.0160.00314.02
5.5.160.0050.02617.10
5.5.150.0080.03117.33
5.5.140.0070.04017.28
5.5.130.0030.02817.10
5.5.120.0080.02217.13
5.5.110.0160.02517.04
5.5.100.0180.03017.06
5.5.90.0100.02617.23
5.5.80.0090.02217.17
5.5.70.0150.01817.24
5.5.60.0070.02417.15
5.5.50.0030.02616.96
5.5.40.0100.02617.17
5.5.30.0070.03417.09
5.5.20.0080.02417.11
5.5.10.0060.02117.03
5.5.00.0060.02517.09
5.4.450.0090.04715.35
5.4.440.0090.03415.29
5.4.430.0130.03815.28
5.4.420.0070.04815.46
5.4.410.0140.03815.20
5.4.400.0090.03715.08
5.4.390.0070.04214.91
5.4.380.0080.04315.14
5.4.370.0130.04015.03
5.4.360.0050.02515.04
5.4.350.0040.02715.13
5.4.340.0090.02514.82
5.4.330.0090.01210.89
5.4.320.0060.02315.08
5.4.310.0130.03615.06
5.4.300.0090.02814.96
5.4.290.0070.02514.90
5.4.280.0050.02215.05
5.4.270.0090.03715.00
5.4.260.0080.02315.34
5.4.250.0050.04115.13
5.4.240.0130.01515.30
5.4.230.0080.01815.08
5.4.220.0040.04615.26
5.4.210.0090.02214.93
5.4.200.0150.02214.97
5.4.190.0110.02515.10
5.4.180.0080.02015.01
5.4.170.0110.02815.06
5.4.160.0090.01915.08
5.4.150.0080.04214.95
5.4.140.0050.02113.70
5.4.130.0030.02313.62
5.4.120.0030.02713.60
5.4.110.0060.03113.72
5.4.100.0090.02213.64
5.4.90.0050.02513.71
5.4.80.0050.02813.55
5.4.70.0060.03113.75
5.4.60.0070.02013.57
5.4.50.0120.01713.68
5.4.40.0100.02213.84
5.4.30.0090.02913.68
5.4.20.0060.02113.88
5.4.10.0060.02213.76
5.4.00.0080.01713.39
5.3.290.0060.02312.78
5.3.280.0070.02012.72
5.3.270.0070.02212.77
5.3.260.0030.02212.69
5.3.250.0040.02212.73
5.3.240.0090.02212.70
5.3.230.0060.03112.69
5.3.220.0120.02812.76
5.3.210.0080.02612.65
5.3.200.0110.03512.69
5.3.190.0060.02512.70
5.3.180.0080.01912.72
5.3.170.0070.03212.68
5.3.160.0060.02812.66
5.3.150.0030.02712.69
5.3.140.0050.02712.71
5.3.130.0100.02012.65
5.3.120.0020.03212.66
5.3.110.0060.02312.71
5.3.100.0020.02612.42
5.3.90.0060.02212.38
5.3.80.0070.02012.48
5.3.70.0050.02412.41
5.3.60.0070.02712.46
5.3.50.0120.03012.39
5.3.40.0080.04312.41
5.3.30.0080.04212.39
5.3.20.0080.03812.21
5.3.10.0080.03812.22
5.3.00.0110.04012.28
5.2.170.0030.05011.27
5.2.160.0100.06011.19
5.2.150.0100.06311.23
5.2.140.0030.05311.14
5.2.130.0070.06311.14
5.2.120.0030.04711.17
5.2.110.0000.06711.13
5.2.100.0070.06011.13
5.2.90.0070.06311.14
5.2.80.0000.05311.14
5.2.70.0070.05311.18
5.2.60.0030.06011.00
5.2.50.0100.06011.03
5.2.40.0100.03311.05
5.2.30.0070.06010.88
5.2.20.0070.06010.88
5.2.10.0070.05710.86
5.2.00.0070.06010.86
5.1.60.0070.05310.86
5.1.50.0100.05310.86
5.1.40.0030.05710.86
5.1.30.0070.06010.86
5.1.20.0030.04310.86
5.1.10.0030.06010.86
5.1.00.0030.05710.86
5.0.50.0100.04310.86
5.0.40.0000.05310.86
5.0.30.0100.05710.86
5.0.20.0100.04010.86
5.0.10.0030.04710.86
5.0.00.0070.06310.86
4.4.90.0000.02710.86
4.4.80.0030.03010.86
4.4.70.0030.02310.86
4.4.60.0000.03710.86
4.4.50.0030.03710.86
4.4.40.0030.05010.86
4.4.30.0030.03310.86
4.4.20.0000.03010.86
4.4.10.0000.03710.86
4.4.00.0170.04010.86
4.3.110.0000.03710.86
4.3.100.0030.03310.86
4.3.90.0000.03010.86
4.3.80.0000.05710.86
4.3.70.0030.03310.86
4.3.60.0030.03010.86
4.3.50.0030.03010.86
4.3.40.0000.05310.86
4.3.30.0000.03710.86
4.3.20.0000.03710.86
4.3.10.0000.03710.86
4.3.00.0030.03310.86

preferences:
41.47 ms | 401 KiB | 5 Q