3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Instantiator { public $dependencies = []; public function instantiate($type) { return $this->instantiateInternal($type, []); } private function instantiateInternal($type, array $stack) { if (in_array($type, $stack)) { throw new Exception(vsprintf('Cycle detected for `%s` as %s', [ $type, print_r($stack, true), ])); } $stack[] = $type; $graph = []; if (isset($this->dependencies[$type])) { foreach ($this->dependencies[$type] as $dependentType) { $graph[$dependentType] = $this->instantiateInternal($dependentType, $stack); } } return $graph; } } $i1 = new Instantiator(); $i1->dependencies = [ 'A' => ['B', 'C'], 'B' => ['D'], 'C' => ['D'], 'D' => ['E'], ]; var_dump($i1->instantiate('A')); $i2 = new Instantiator(); $i2->dependencies = [ 'A' => ['B', 'C'], 'B' => ['D'], 'C' => ['D'], 'D' => ['A'], ]; var_dump($i2->instantiate('A'));

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.0140.00718.55
8.3.50.0130.00922.05
8.3.40.0040.01518.82
8.3.30.0120.00919.09
8.3.20.0050.00220.39
8.3.10.0070.00722.10
8.3.00.0080.00020.56
8.2.180.0120.00616.50
8.2.170.0060.00922.96
8.2.160.0120.00422.12
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0050.00326.16
8.2.120.0080.00019.36
8.2.110.0030.00621.00
8.2.100.0060.00617.85
8.2.90.0080.00018.03
8.2.80.0050.00317.97
8.2.70.0050.00317.63
8.2.60.0060.00317.93
8.2.50.0050.00318.07
8.2.40.0060.00318.22
8.2.30.0000.00718.12
8.2.20.0000.00817.64
8.2.10.0000.00817.75
8.2.00.0040.00417.68
8.1.280.0090.00925.92
8.1.270.0060.00321.88
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0040.00422.20
8.1.230.0070.00420.96
8.1.220.0000.00917.79
8.1.210.0030.00520.04
8.1.200.0060.00317.35
8.1.190.0040.00417.53
8.1.180.0040.00418.77
8.1.170.0040.00418.50
8.1.160.0040.00422.09
8.1.150.0000.00918.57
8.1.140.0000.00717.47
8.1.130.0030.00317.81
8.1.120.0040.00417.47
8.1.110.0040.00417.38
8.1.100.0000.00717.38
8.1.90.0070.00017.37
8.1.80.0070.00017.47
8.1.70.0000.00717.43
8.1.60.0050.00317.61
8.1.50.0000.00817.54
8.1.40.0030.00617.51
8.1.30.0050.00317.52
8.1.20.0060.00317.58
8.1.10.0080.00017.61
8.1.00.0060.00317.55
8.0.300.0030.00520.07
8.0.290.0050.00316.75
8.0.280.0030.00318.47
8.0.270.0040.00417.28
8.0.260.0030.00316.78
8.0.250.0030.00617.03
8.0.240.0040.00417.05
8.0.230.0060.00016.94
8.0.220.0030.00516.89
8.0.210.0020.00516.88
8.0.200.0090.00016.93
8.0.190.0040.00417.05
8.0.180.0040.00416.95
8.0.170.0000.00817.04
8.0.160.0050.00316.85
8.0.150.0070.00017.00
8.0.140.0070.00016.84
8.0.130.0000.00613.39
8.0.120.0030.00516.97
8.0.110.0060.00316.91
8.0.100.0040.00416.91
8.0.90.0070.00016.91
8.0.80.0150.00316.98
8.0.70.0000.00717.05
8.0.60.0040.00417.04
8.0.50.0040.00416.84
8.0.30.0100.01217.15
8.0.20.0100.00917.40
8.0.10.0040.00417.16
8.0.00.0090.00916.86
7.4.330.0050.00015.14
7.4.320.0030.00316.63
7.4.300.0000.00616.64
7.4.290.0030.00316.43
7.4.280.0000.00716.52
7.4.270.0000.00816.61
7.4.260.0030.00416.65
7.4.250.0040.00416.63
7.4.240.0060.00116.54
7.4.230.0030.00316.55
7.4.220.0060.01316.64
7.4.210.0100.00516.68
7.4.200.0000.00716.69
7.4.190.0000.00716.73
7.4.160.0100.00616.49
7.4.150.0060.01217.40
7.4.140.0050.01517.86
7.4.130.0110.00716.63
7.4.120.0120.00516.59
7.4.110.0070.01416.41
7.4.100.0070.01416.82
7.4.90.0090.00916.68
7.4.80.0150.00319.39
7.4.70.0070.01016.37
7.4.60.0100.00616.51
7.4.50.0030.00616.52
7.4.40.0060.01022.77
7.4.30.0080.00816.52
7.4.00.0030.01315.09
7.3.330.0030.00313.47
7.3.320.0000.00613.25
7.3.310.0040.00416.31
7.3.300.0000.00616.32
7.3.290.0100.00316.36
7.3.280.0050.01316.40
7.3.270.0120.00617.40
7.3.260.0140.00516.36
7.3.250.0160.00216.43
7.3.240.0070.01516.50
7.3.230.0140.00416.39
7.3.210.0060.01216.42
7.3.200.0100.01019.39
7.3.190.0060.01116.69
7.3.180.0160.00016.43
7.3.170.0030.01316.45
7.3.160.0090.00616.55
7.3.120.0080.00815.13
7.3.10.0190.00616.54
7.3.00.0140.00016.34
7.2.330.0110.00616.91
7.2.320.0120.00916.86
7.2.310.0070.01016.50
7.2.300.0130.00716.38
7.2.290.0080.00916.88
7.2.130.0120.00616.78
7.2.120.0140.00616.59
7.2.110.0120.00416.52
7.2.100.0150.00316.74
7.2.90.0030.01116.81
7.2.80.0140.00716.64
7.2.70.0040.01116.56
7.2.60.0080.00616.87
7.2.50.0130.00316.88
7.2.40.0130.00717.04
7.2.30.0190.00316.96
7.2.20.0060.01016.51
7.2.10.0030.00716.74
7.2.00.0050.01018.31
7.1.250.0110.00315.68
7.1.200.0100.01015.59
7.1.70.0000.00717.19
7.1.60.0050.00517.03
7.1.50.0030.01017.11
7.1.00.0100.08322.43
7.0.200.0030.01216.66
7.0.140.0070.07321.96
7.0.60.0200.07019.93
7.0.50.0070.07317.91
7.0.40.0070.04320.40
7.0.30.0370.07720.08
7.0.20.0270.04720.34
7.0.10.0100.07720.07
7.0.00.0070.07320.06
5.6.280.0030.07321.05
5.6.210.0030.06020.55
5.6.200.0130.07018.19
5.6.190.0030.09320.61
5.6.180.0070.05720.61
5.6.170.0200.07720.54
5.6.160.0070.08320.52
5.6.150.0030.06318.22
5.6.140.0100.05718.18
5.6.130.0100.06318.15
5.6.120.0100.03721.05
5.6.110.0100.08020.98
5.6.100.0070.08320.97
5.6.90.0070.08020.88
5.6.80.0030.07020.37
5.5.350.0030.08320.41
5.5.340.0070.03317.96
5.5.330.0070.06720.57
5.5.320.0200.04720.52
5.5.310.0330.04720.28
5.5.300.0170.07317.93
5.5.290.0070.06017.95
5.5.280.0000.06320.86
5.5.270.0100.08020.96
5.5.260.0070.07020.68
5.5.250.0070.08320.70
5.5.240.0100.07020.16
5.4.450.0170.05719.52
5.4.440.0300.07019.46
5.4.430.0170.04319.40
5.4.420.0170.04019.41
5.4.410.0230.05719.52
5.4.400.0300.03719.23
5.4.390.0230.07018.99
5.4.380.0200.07319.22
5.4.370.0230.05319.15
5.4.360.0400.06019.22
5.4.350.0270.05719.15
5.4.340.0230.06019.08
5.4.320.0170.05319.25
5.4.310.0230.07019.07
5.4.300.0200.07719.22
5.4.290.0400.05318.94
5.4.280.0300.04018.87
5.4.270.0270.06319.14
5.4.260.0270.06018.94
5.4.250.0370.06019.07
5.4.240.0270.06719.19
5.4.230.0300.05019.18
5.4.220.0230.07019.15
5.4.210.0230.07319.14
5.4.200.0300.08319.12
5.4.190.0300.04019.08
5.4.180.0200.08019.08
5.4.170.0270.07318.98
5.4.160.0230.04718.97
5.4.150.0270.04719.20
5.4.140.0270.06716.43
5.4.130.0400.05716.42
5.4.120.0230.07016.53
5.4.110.0230.03316.29
5.4.100.0270.06716.48
5.4.90.0230.06016.58
5.4.80.0230.03316.59
5.4.70.0170.05716.40
5.4.60.0230.07016.28
5.4.50.0230.06316.50
5.4.40.0230.05316.55
5.4.30.0330.06316.43
5.4.20.0230.06716.48
5.4.10.0270.04016.51
5.4.00.0370.04315.83
5.3.290.0230.07314.71
5.3.280.0230.05014.63
5.3.270.0270.07014.57
5.3.260.0230.07014.59
5.3.250.0230.04314.53
5.3.240.0270.06314.57
5.3.230.0200.04714.60
5.3.220.0230.04314.58
5.3.210.0230.04014.53
5.3.200.0300.04714.78
5.3.190.0300.06314.56
5.3.180.0230.05014.56
5.3.170.0230.04314.54
5.3.160.0270.07014.56
5.3.150.0200.04714.71
5.3.140.0200.06014.64
5.3.130.0300.06314.54
5.3.120.0200.07714.52
5.3.110.0300.05314.70
5.3.100.0270.04714.05
5.3.90.0200.05313.94
5.3.80.0230.06714.02
5.3.70.0170.05014.09
5.3.60.0300.06013.90
5.3.50.0300.06013.84
5.3.40.0300.04014.04
5.3.30.0300.06014.02
5.3.20.0230.03713.59
5.3.10.0270.07013.58
5.3.00.0370.05313.65
5.2.170.0230.06012.42
5.2.160.0230.06012.42
5.2.150.0200.05712.42
5.2.140.0230.03012.42
5.2.130.0200.05712.42
5.2.120.0130.04712.42
5.2.110.0270.05012.42
5.2.100.0130.06012.42
5.2.90.0170.05312.42
5.2.80.0100.06312.42
5.2.70.0270.05712.42
5.2.60.0200.06012.42
5.2.50.0270.02712.42
5.2.40.0230.05012.42
5.2.30.0200.02312.42
5.2.20.0170.05712.42
5.2.10.0170.03312.42
5.2.00.0200.06312.42
5.1.60.0200.04712.42
5.1.50.0170.02712.42
5.1.40.0200.04712.42
5.1.30.0230.04712.42
5.1.20.0230.04712.42
5.1.10.0100.03312.42
5.1.00.0200.04012.42
5.0.50.0100.01712.42
5.0.40.0170.03712.42
5.0.30.0030.06012.42
5.0.20.0030.03012.42
5.0.10.0070.03312.42
5.0.00.0070.06312.42
4.4.90.0100.02012.42
4.4.80.0070.02312.42
4.4.70.0070.02312.42
4.4.60.0070.02012.42
4.4.50.0100.01712.42
4.4.40.0100.04312.42
4.4.30.0030.02012.42
4.4.20.0130.03312.42
4.4.10.0070.02012.42
4.4.00.0070.04012.42
4.3.110.0100.03012.42
4.3.100.0070.02712.42
4.3.90.0070.02012.42
4.3.80.0170.04712.42
4.3.70.0070.03312.42
4.3.60.0070.03312.42
4.3.50.0100.02712.42
4.3.40.0070.03712.42
4.3.30.0070.03312.42
4.3.20.0000.02712.42
4.3.10.0130.03312.42
4.3.00.0030.03312.42

preferences:
50.55 ms | 401 KiB | 5 Q