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('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.70.0100.01016.63
8.3.60.0110.00318.33
8.3.50.0050.01221.92
8.3.40.0070.01418.88
8.3.30.0110.00418.80
8.3.20.0000.00818.95
8.3.10.0050.00320.36
8.3.00.0050.00323.71
8.2.180.0080.01516.88
8.2.170.0130.00322.96
8.2.160.0100.00320.27
8.2.150.0140.00724.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0080.00019.38
8.2.110.0040.00422.08
8.2.100.0060.00617.89
8.2.90.0000.00917.88
8.2.80.0000.00817.97
8.2.70.0060.00317.93
8.2.60.0040.00417.93
8.2.50.0000.00818.10
8.2.40.0030.00520.64
8.2.30.0000.00819.82
8.2.20.0060.00317.77
8.2.10.0040.00417.75
8.2.00.0040.00417.70
8.1.280.0000.01625.92
8.1.270.0040.00423.99
8.1.260.0040.01226.35
8.1.250.0040.00428.09
8.1.240.0030.00622.54
8.1.230.0060.00619.22
8.1.220.0000.00817.74
8.1.210.0060.00318.77
8.1.200.0030.00617.48
8.1.190.0060.00317.22
8.1.180.0030.00618.10
8.1.170.0050.00318.64
8.1.160.0000.00718.82
8.1.150.0050.00318.64
8.1.140.0070.00017.51
8.1.130.0030.00317.75
8.1.120.0040.00417.34
8.1.110.0040.00417.52
8.1.100.0040.00417.48
8.1.90.0000.00817.53
8.1.80.0030.00417.44
8.1.70.0030.00317.46
8.1.60.0030.00617.48
8.1.50.0030.00517.44
8.1.40.0030.00617.57
8.1.30.0080.00017.70
8.1.20.0000.00817.66
8.1.10.0000.00717.62
8.1.00.0050.00317.61
8.0.300.0000.00719.70
8.0.290.0040.00416.88
8.0.280.0030.00318.39
8.0.270.0040.00417.20
8.0.260.0070.00016.88
8.0.250.0030.00717.05
8.0.240.0000.00816.96
8.0.230.0000.00717.05
8.0.220.0000.00717.03
8.0.210.0040.00416.97
8.0.200.0000.00616.91
8.0.190.0000.00817.04
8.0.180.0070.00017.06
8.0.170.0040.00416.98
8.0.160.0000.00716.95
8.0.150.0050.00317.01
8.0.140.0040.00416.95
8.0.130.0060.00313.36
8.0.120.0040.00416.93
8.0.110.0000.00716.85
8.0.100.0040.00416.86
8.0.90.0030.00516.86
8.0.80.0060.00917.00
8.0.70.0000.00716.88
8.0.60.0040.00416.98
8.0.50.0030.00517.00
8.0.30.0120.00617.14
8.0.20.0090.00917.40
8.0.10.0080.00017.06
8.0.00.0070.01516.69
7.4.330.0030.00314.88
7.4.320.0030.00316.48
7.4.300.0000.00616.64
7.4.290.0040.00416.47
7.4.280.0070.00016.55
7.4.270.0080.00016.62
7.4.260.0030.00513.23
7.4.250.0060.00316.41
7.4.240.0050.00316.57
7.4.230.0030.00516.29
7.4.220.0070.01016.55
7.4.210.0080.00816.54
7.4.200.0000.00816.74
7.4.190.0030.00316.49
7.4.160.0090.00916.50
7.4.150.0060.01617.40
7.4.140.0050.01317.86
7.4.130.0060.01116.60
7.4.120.0080.01016.47
7.4.110.0130.00916.58
7.4.100.0030.01416.56
7.4.90.0060.01216.72
7.4.80.0030.01319.37
7.4.70.0140.01116.47
7.4.60.0050.01416.46
7.4.50.0080.00016.66
7.4.40.0090.00622.27
7.4.30.0030.01716.71
7.4.00.0070.01015.32
7.3.330.0030.00313.57
7.3.320.0030.00313.32
7.3.310.0070.00016.51
7.3.300.0000.00716.34
7.3.290.0030.01016.45
7.3.280.0060.00916.45
7.3.270.0120.00417.40
7.3.260.0140.00518.24
7.3.250.0120.00916.39
7.3.240.0080.01016.57
7.3.230.0060.01216.48
7.3.210.0100.01316.45
7.3.200.0170.00019.39
7.3.190.0160.00616.43
7.3.180.0100.00716.43
7.3.170.0100.01016.58
7.3.160.0040.01416.38
7.3.120.0110.00315.10
7.3.10.0070.00716.76
7.3.00.0040.00716.52
7.2.330.0090.00916.70
7.2.320.0070.01016.80
7.2.310.0030.01416.70
7.2.300.0100.00716.79
7.2.290.0100.00716.77
7.2.130.0030.01016.94
7.2.120.0000.00917.06
7.2.110.0090.00316.95
7.2.100.0080.00316.93
7.2.90.0000.00916.74
7.2.80.0100.00317.00
7.2.70.0100.00317.12
7.2.60.0090.00316.91
7.2.50.0090.00016.88
7.2.40.0000.00917.06
7.2.30.0000.01117.02
7.2.20.0040.00816.96
7.2.10.0000.01217.11
7.2.00.0060.00818.17
7.1.250.0070.00316.04
7.1.100.0030.01018.08
7.1.70.0000.00717.09
7.1.60.0070.01719.40
7.1.50.0130.00917.07
7.1.00.0070.04022.45
7.0.200.0130.00716.50
7.0.140.0100.05722.15
7.0.70.0070.05321.68
7.0.60.0070.08021.72
7.0.50.0030.08722.19
7.0.40.0030.08020.13
7.0.30.0100.07319.90
7.0.20.0030.08320.11
7.0.10.0000.06720.05
7.0.00.0030.08320.09
5.6.280.0170.06320.91
5.6.220.0070.07320.49
5.6.210.0030.08320.71
5.6.200.0030.08321.03
5.6.190.0000.05021.00
5.6.180.0030.08721.11
5.6.170.0130.06720.95
5.6.160.0000.08321.05
5.6.150.0030.08721.09
5.6.140.0030.08321.08
5.6.130.0000.08321.11
5.6.120.0070.05321.07
5.6.110.0070.08320.95
5.6.100.0070.07321.00
5.6.90.0030.05021.06
5.6.80.0100.05720.41
5.6.70.0000.05720.41
5.6.60.0100.04720.48
5.6.50.0030.07320.38
5.6.40.0030.03720.35
5.6.30.0030.05320.39
5.6.20.0000.05020.32
5.6.10.0000.04020.43
5.6.00.0000.04020.28
5.5.360.0000.08020.45
5.5.350.0100.07320.30
5.5.340.0130.06720.88
5.5.330.0070.07720.89
5.5.320.0070.08020.76
5.5.310.0000.08320.90
5.5.300.0000.06320.77
5.5.290.0130.08020.86
5.5.280.0070.07720.64
5.5.270.0030.07720.79
5.5.260.0030.08320.84
5.5.250.0070.07320.55
5.5.240.0100.07320.24
5.5.230.0100.07320.02
5.5.220.0030.07320.26
5.5.210.0070.08020.13
5.5.200.0030.03720.24
5.5.190.0000.05720.15
5.5.180.0000.06320.13
5.5.160.0030.09320.23
5.5.150.0030.10020.26
5.5.140.0000.04720.08
5.5.130.0030.05020.07
5.5.120.0070.08020.20
5.5.110.0070.07720.11
5.5.100.0130.07020.13
5.5.90.0030.08020.06
5.5.80.0000.06320.07
5.5.70.0000.08020.13
5.5.60.0030.06320.05
5.5.50.0030.08320.07
5.5.40.0100.07020.09
5.5.30.0000.08720.02
5.5.20.0170.07020.05
5.5.10.0070.07020.05
5.5.00.0030.08020.10
5.4.450.0030.07019.53
5.4.440.0030.08019.34
5.4.430.0070.08019.55
5.4.420.0000.08319.35
5.4.410.0000.06719.39
5.4.400.0030.07319.11
5.4.390.0100.06718.83
5.4.380.0030.06318.93
5.4.370.0030.07019.21
5.4.360.0000.04019.21
5.4.350.0000.04019.20
5.4.340.0000.07719.11
5.4.320.0030.05019.08
5.4.310.0000.06319.03
5.4.300.0030.06019.12
5.4.290.0030.07319.14
5.4.280.0070.06718.93
5.4.270.0070.07019.01
5.4.260.0030.07719.08
5.4.250.0100.06319.02
5.4.240.0000.07719.21
5.4.230.0000.07319.01
5.4.220.0000.08319.02
5.4.210.0070.07719.10
5.4.200.0070.07319.19
5.4.190.0100.07019.02
5.4.180.0130.06319.07
5.4.170.0030.06019.00
5.4.160.0100.06319.05
5.4.150.0030.06019.19
5.4.140.0030.07316.39
5.4.130.0000.07716.35
5.4.120.0000.04316.44
5.4.110.0070.06716.40
5.4.100.0070.06316.38
5.4.90.0000.04316.40
5.4.80.0000.04716.32
5.4.70.0070.06716.48
5.4.60.0070.06716.46
5.4.50.0070.06016.45
5.4.40.0000.07716.35
5.4.30.0000.07016.34
5.4.20.0000.06016.34
5.4.10.0000.07716.32
5.4.00.0030.06715.84
5.3.290.0030.07014.60
5.3.280.0000.07014.60
5.3.270.0030.07314.68
5.3.260.0000.07714.76
5.3.250.0030.07314.59
5.3.240.0000.06314.65
5.3.230.0070.03714.68
5.3.220.0030.06714.59
5.3.210.0070.05314.64
5.3.200.0100.06714.56
5.3.190.0000.05014.65
5.3.180.0000.07714.53
5.3.170.0030.06014.72
5.3.160.0030.07714.55
5.3.150.0070.06014.63
5.3.140.0070.07714.71
5.3.130.0070.07314.51
5.3.120.0030.07014.53
5.3.110.0100.07314.62
5.3.100.0000.08014.11
5.3.90.0000.07013.96
5.3.80.0030.07314.12
5.3.70.0030.06013.96
5.3.60.0030.06713.99
5.3.50.0000.06014.01
5.3.40.0000.03713.93
5.3.30.0000.06313.93
5.3.20.0070.06713.77
5.3.10.0000.07313.56
5.3.00.0030.06013.77
5.2.170.0030.06312.54
5.2.160.0100.05312.54
5.2.150.0000.03012.54
5.2.140.0030.06012.54
5.2.130.0000.06312.54
5.2.120.0000.06312.54
5.2.110.0070.05712.54
5.2.100.0100.06012.54
5.2.90.0070.05312.54
5.2.80.0030.06312.54
5.2.70.0070.05712.54
5.2.60.0070.03712.54
5.2.50.0000.03012.54
5.2.40.0000.03012.54
5.2.30.0070.02312.54
5.2.20.0000.03012.54
5.2.10.0000.03012.54
5.2.00.0000.03012.54
5.1.60.0030.02312.54
5.1.50.0000.02312.54
5.1.40.0000.02712.54
5.1.30.0030.02312.54
5.1.20.0000.02712.54
5.1.10.0000.02012.54
5.1.00.0030.02012.54
5.0.50.0000.02012.54
5.0.40.0030.01712.54
5.0.30.0000.03712.54
5.0.20.0000.02012.54
5.0.10.0000.04312.54
5.0.00.0030.03012.54
4.4.90.0070.02712.54
4.4.80.0000.01712.54
4.4.70.0030.01312.54
4.4.60.0000.01312.54
4.4.50.0000.01712.54
4.4.40.0000.02312.54
4.4.30.0000.01312.54
4.4.20.0000.01312.54
4.4.10.0000.01312.54
4.4.00.0000.02312.54
4.3.110.0000.01312.54
4.3.100.0000.01712.54
4.3.90.0000.01312.54
4.3.80.0000.02712.54
4.3.70.0030.02712.54
4.3.60.0000.02012.54
4.3.50.0000.03712.54
4.3.40.0030.05012.54
4.3.30.0030.03312.54
4.3.20.0030.03712.54
4.3.10.0030.03012.54
4.3.00.0000.02712.54

preferences:
48.52 ms | 401 KiB | 5 Q