3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $foo; protected function __construct($spam){ $this->foo = $spam; } public function getFoo() { return $this->foo; } } function instantiate_private_ctor($class /*, $...args */) { $args = array_slice(func_get_args(), 1); $extClass = $class . '__Ext'; if (!class_exists($extClass)) { $ns = ltrim(dirname($extClass), '\\'); $name = basename($extClass); $namespace = $ns && $ns !== '.' ? 'namespace ' . $ns . ';' : ''; eval(" $namespace class $name extends $class { public function __construct() { \$args = func_get_args(); call_user_func_array('parent::__construct', \$args); } } "); } $reflClass = new \ReflectionClass($extClass); return $reflClass->newInstanceArgs($args); } $args = 'bacon'; $class = 'Foo'; $reflClass = new \ReflectionClass($class); $instance = instantiate_private_ctor($class, 'bacon'); echo $instance->getFoo();

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.68
8.3.50.0120.00722.02
8.3.40.0090.00618.79
8.3.30.0120.00319.05
8.3.20.0050.00220.29
8.3.10.0040.00423.65
8.3.00.0050.00520.94
8.2.180.0110.00716.63
8.2.170.0150.00022.96
8.2.160.0140.00020.39
8.2.150.0000.00724.18
8.2.140.0000.00724.66
8.2.130.0080.00026.16
8.2.120.0040.00419.25
8.2.110.0060.00322.12
8.2.100.0060.00620.38
8.2.90.0040.00419.16
8.2.80.0000.00817.97
8.2.70.0030.00717.59
8.2.60.0050.00317.93
8.2.50.0000.00818.07
8.2.40.0000.00819.94
8.2.30.0030.00618.36
8.2.20.0030.00617.55
8.2.10.0000.00718.02
8.2.00.0040.00419.40
8.1.280.0060.01025.92
8.1.270.0060.00323.91
8.1.260.0000.00726.35
8.1.250.0080.00028.09
8.1.240.0120.00623.91
8.1.230.0080.00419.09
8.1.220.0000.00817.74
8.1.210.0030.00618.77
8.1.200.0030.00617.35
8.1.190.0000.00817.23
8.1.180.0060.00318.10
8.1.170.0060.00318.52
8.1.160.0050.00222.07
8.1.150.0000.00718.64
8.1.140.0040.00417.50
8.1.130.0000.00717.84
8.1.120.0000.00717.46
8.1.110.0040.00417.34
8.1.100.0000.00717.50
8.1.90.0000.00717.37
8.1.80.0040.00417.50
8.1.70.0070.00017.35
8.1.60.0040.00417.56
8.1.50.0040.00417.43
8.1.40.0070.00017.49
8.1.30.0040.00417.63
8.1.20.0040.00417.68
8.1.10.0040.00717.46
8.1.00.0030.00717.52
8.0.300.0060.00318.77
8.0.290.0060.00316.63
8.0.280.0030.00318.45
8.0.270.0000.00717.18
8.0.260.0000.00717.19
8.0.250.0040.00416.88
8.0.240.0040.00416.90
8.0.230.0040.00416.95
8.0.220.0030.00516.92
8.0.210.0020.00516.91
8.0.200.0000.00616.90
8.0.190.0070.00016.94
8.0.180.0080.00416.91
8.0.170.0040.00416.97
8.0.160.0000.00716.89
8.0.150.0000.00716.91
8.0.140.0040.00416.76
8.0.130.0040.00413.39
8.0.120.0060.00115.07
8.0.110.0020.00515.05
8.0.100.0020.00615.10
8.0.90.0000.00815.15
8.0.80.0040.01115.07
8.0.70.0050.00314.99
8.0.60.0050.00315.09
8.0.50.0040.00415.03
8.0.30.0050.01015.83
8.0.20.0090.00616.05
8.0.10.0030.00615.16
8.0.00.0050.00915.59
7.4.330.0050.00015.20
7.4.320.0030.00316.51
7.4.300.0000.00716.46
7.4.290.0000.00716.55
7.4.280.0050.00316.51
7.4.270.0030.00316.48
7.4.260.0030.00716.51
7.4.250.0070.00114.94
7.4.240.0040.00415.49
7.4.230.0040.00414.81
7.4.220.0060.00814.91
7.4.210.0120.00515.01
7.4.200.0060.00414.92
7.4.190.0060.00613.35
7.4.180.0070.00013.29
7.4.160.0060.00814.91
7.4.150.0070.00515.30
7.4.140.0070.00916.32
7.4.130.0080.00815.40
7.4.120.0090.00715.52
7.4.110.0100.00314.95
7.4.100.0120.00214.98
7.4.90.0040.00714.81
7.4.80.0070.00616.34
7.4.70.0060.00714.85
7.4.60.0060.00714.90
7.4.50.0000.00514.71
7.4.40.0050.00614.73
7.4.30.0050.00714.75
7.4.20.0050.00313.14
7.4.10.0020.01114.11
7.4.00.0050.00814.25
7.3.330.0000.00613.31
7.3.320.0020.00213.20
7.3.310.0020.00614.89
7.3.300.0040.00314.77
7.3.290.0050.00514.85
7.3.280.0070.00915.62
7.3.270.0110.00215.37
7.3.260.0100.00614.80
7.3.250.0080.00615.50
7.3.240.0080.00615.00
7.3.230.0060.00614.90
7.3.220.0040.00413.15
7.3.210.0090.00614.83
7.3.200.0060.00916.32
7.3.190.0060.00914.82
7.3.180.0060.00514.81
7.3.170.0080.00414.99
7.3.160.0060.00614.76
7.3.150.0050.00313.10
7.3.140.0070.00013.24
7.3.130.0100.00314.14
7.3.120.0080.00514.49
7.3.110.0050.00713.96
7.3.100.0020.00913.97
7.3.90.0050.00314.30
7.3.80.0040.00714.17
7.3.70.0020.00814.17
7.3.60.0060.00514.13
7.3.50.0060.00414.25
7.3.40.0030.00514.21
7.3.30.0060.00413.97
7.3.20.0070.00415.91
7.3.10.0030.00515.90
7.3.00.0020.00716.08
7.2.340.0080.00413.21
7.2.330.0100.00515.01
7.2.320.0090.00515.07
7.2.310.0090.00614.98
7.2.300.0120.00315.00
7.2.290.0090.00714.89
7.2.280.0090.00313.20
7.2.270.0090.00313.38
7.2.260.0050.00914.34
7.2.250.0100.00514.37
7.2.240.0100.00414.16
7.2.230.0100.00314.00
7.2.220.0090.00614.21
7.2.210.0070.00614.10
7.2.200.0040.01014.30
7.2.190.0090.00714.33
7.2.180.0040.01014.21
7.2.170.0070.00614.30
7.2.160.0030.01214.22
7.2.150.0090.00516.16
7.2.140.0070.00616.16
7.2.130.0080.00416.13
7.2.120.0080.00516.22
7.2.110.0080.00416.10
7.2.100.0090.00216.16
7.2.90.0030.01216.12
7.2.80.0080.00516.14
7.2.70.0070.00616.23
7.2.60.0090.00416.24
7.2.50.0080.00616.14
7.2.40.0110.00315.95
7.2.30.0060.00616.08
7.2.20.0110.00116.11
7.2.10.0060.00816.01
7.2.00.0060.00616.26
7.1.330.0060.00815.11
7.1.320.0070.00615.06
7.1.310.0070.00415.10
7.1.300.0060.00614.94
7.1.290.0060.00715.15
7.1.280.0040.01015.02
7.1.270.0060.00615.00
7.1.260.0030.00715.07
7.1.250.0100.00315.02
7.1.240.0060.00515.07
7.1.230.0070.00315.09
7.1.220.0100.00115.07
7.1.210.0070.00315.07
7.1.200.0050.00815.02
7.1.190.0090.00315.17
7.1.180.0050.00815.14
7.1.170.0050.00614.99
7.1.160.0100.00415.02
7.1.150.0060.00614.93
7.1.140.0080.00515.04
7.1.130.0080.00315.00
7.1.120.0020.01115.09
7.1.110.0090.00315.03
7.1.100.0080.00615.03
7.1.90.0060.00515.18
7.1.80.0150.00415.05
7.1.70.0050.00715.65
7.1.60.0110.00516.61
7.1.50.0080.00715.70
7.1.40.0080.00615.01
7.1.30.0060.00715.11
7.1.20.0060.00615.06
7.1.10.0090.00415.07
7.1.00.0060.02817.54
7.0.330.0070.00614.83
7.0.320.0050.00614.80
7.0.310.0060.00614.71
7.0.300.0040.00714.80
7.0.290.0060.00814.76
7.0.280.0090.00414.77
7.0.270.0060.00714.67
7.0.260.0050.00514.68
7.0.250.0120.00214.89
7.0.240.0060.00614.79
7.0.230.0070.00714.90
7.0.220.0040.00814.83
7.0.210.0060.00614.77
7.0.200.0050.00615.49
7.0.190.0080.00514.86
7.0.180.0080.00614.95
7.0.170.0100.00314.87
7.0.160.0050.00814.74
7.0.150.0090.00414.90
7.0.140.0070.02717.16
7.0.130.0090.00614.87
7.0.120.0080.00514.89
7.0.110.0100.00514.76
7.0.100.0050.00814.73
7.0.90.0090.00414.80
7.0.80.0070.00414.87
7.0.70.0060.00814.80
7.0.60.0070.03216.54
7.0.50.0060.02515.88
7.0.40.0060.03215.94
7.0.30.0200.01815.94
7.0.20.0160.02915.93
7.0.10.0070.02615.88
7.0.00.0060.01815.92
5.6.400.0040.00913.61
5.6.390.0080.00413.51
5.6.380.0070.00513.72
5.6.370.0090.00313.71
5.6.360.0070.00513.67
5.6.350.0090.00313.63
5.6.340.0080.00313.71
5.6.330.0080.00413.70
5.6.320.0040.00813.67
5.6.310.0030.01113.58
5.6.300.0090.00313.56
5.6.290.0100.00313.63
5.6.280.0080.02515.99
5.6.270.0040.00913.43
5.6.260.0060.00713.64
5.6.250.0080.00713.69
5.6.240.0090.00413.56
5.6.230.0050.00713.64
5.6.220.0060.00713.63
5.6.210.0100.02415.95
5.6.200.0070.01615.29
5.6.190.0050.02315.98
5.6.180.0130.02116.03
5.6.170.0150.02315.86
5.6.160.0080.03016.00
5.6.150.0050.02215.09
5.6.140.0080.02815.20
5.6.130.0050.02815.10
5.6.120.0080.02516.19
5.6.110.0080.02916.08
5.6.100.0050.01916.08
5.6.90.0090.02816.07
5.6.80.0050.03315.86
5.6.70.1510.01815.92
5.6.60.0110.00213.60
5.6.50.0080.00313.51
5.6.40.0070.00713.56
5.6.30.0070.00413.56
5.6.20.0080.00513.70
5.6.10.0000.01313.44
5.6.00.0070.00513.74
5.5.380.0090.00313.48
5.5.370.0090.00413.70
5.5.360.0100.00513.67
5.5.350.0110.02815.85
5.5.340.0080.01615.00
5.5.330.0090.03115.90
5.5.320.0110.02915.85
5.5.310.0140.02215.83
5.5.300.0080.01515.01
5.5.290.0080.03215.06
5.5.280.0040.03315.91
5.5.270.0030.02016.08
5.5.260.0060.03115.88
5.5.250.0080.03115.86
5.5.240.0050.03015.84
5.5.230.0070.00713.47
5.5.220.0030.01113.42
5.5.210.0070.00513.44
5.5.200.0100.00413.60
5.5.190.0100.00313.31
5.5.180.0060.00613.53
5.5.170.0060.00713.36
5.5.160.0060.00713.44
5.5.150.0090.00413.51
5.5.140.0090.00513.53
5.5.130.0080.00613.52
5.5.120.0080.00513.36
5.5.110.0070.00713.51
5.5.100.0090.00413.36
5.5.90.0070.00413.64
5.5.80.0060.00713.60
5.5.70.0090.00413.45
5.5.60.0050.00713.32
5.5.50.0060.00613.65
5.5.40.0060.00713.45
5.5.30.0070.00713.46
5.5.20.0050.00813.64
5.5.10.0080.00313.51
5.5.00.0040.01013.34
5.4.450.0250.01920.29
5.4.440.0100.01819.11
5.4.430.0140.01819.26
5.4.420.0140.01819.16
5.4.410.0170.01418.37
5.4.400.0120.01618.40
5.4.390.0090.01918.39
5.4.380.0140.02114.08
5.4.370.0080.02114.19
5.4.360.0100.02114.10
5.4.350.0060.02614.21
5.4.340.0140.01814.13
5.4.330.0030.00611.89
5.4.320.0050.01612.15
5.4.310.0060.01611.95
5.4.300.0080.01812.07
5.4.290.0070.01612.07
5.4.280.0070.01812.13
5.4.270.0060.01711.94
5.4.260.0070.01612.14
5.4.250.0050.01912.11
5.4.240.0060.01612.11
5.4.230.0060.01511.96
5.4.220.0060.01412.09
5.4.210.0050.01612.00
5.4.200.0080.01812.06
5.4.190.0030.01812.00
5.4.180.0050.01612.07
5.4.170.0060.01612.06
5.4.160.0060.01412.05
5.4.150.0030.01812.09
5.4.140.0060.01811.97
5.4.130.0060.01611.91
5.4.120.0090.01411.96
5.4.110.0050.01911.92
5.4.100.0060.01811.86
5.4.90.0070.01511.94
5.4.80.0050.01712.02
5.4.70.0070.01611.91
5.4.60.0070.01411.91
5.4.50.0080.01411.99
5.4.40.0040.01711.94
5.4.30.0050.01511.96
5.4.20.0050.01611.87
5.4.10.0030.02011.98
5.4.00.0060.01511.70
5.3.290.0040.01712.32
5.3.280.0060.01512.14
5.3.270.0080.01512.18
5.3.260.0060.01712.23
5.3.250.0070.01412.16
5.3.240.0080.01412.02
5.3.230.0080.01612.09
5.3.220.0060.01811.99
5.3.210.0080.02012.02
5.3.200.0040.01911.96
5.3.190.0080.01912.00
5.3.180.0060.01612.09
5.3.170.0060.01612.14
5.3.160.0060.01612.04
5.3.150.0060.01612.09
5.3.140.0070.02012.07
5.3.130.0070.01612.02
5.3.120.0060.01812.09
5.3.110.0080.01312.04
5.3.100.0060.01711.82
5.3.90.0070.01512.01
5.3.80.0060.01611.79
5.3.70.0080.01711.81
5.3.60.0070.02011.95
5.3.50.0050.01811.85
5.3.40.0090.01211.79
5.3.30.0110.01211.98
5.3.20.0080.01511.75
5.3.10.0070.01611.62
5.3.00.0060.01711.71
5.2.170.0040.01810.58
5.2.160.0050.01610.67
5.2.150.0060.01810.57
5.2.140.0040.02210.62
5.2.130.0060.01610.55
5.2.120.0070.01410.55
5.2.110.0040.02510.55
5.2.100.0030.01910.55
5.2.90.0080.01410.60
5.2.80.0060.01610.49
5.2.70.0040.02510.59
5.2.60.0050.02310.48
5.2.50.0040.01810.47
5.2.40.0040.01610.49
5.2.30.0030.01810.56
5.2.20.0060.01810.51
5.2.10.0030.02410.26
5.2.00.0060.01910.22
5.1.60.0040.0139.49
5.1.50.0050.0189.61
5.1.40.0050.0149.63
5.1.30.0060.0139.85
5.1.20.0050.0209.83
5.1.10.0020.0199.60
5.1.00.0080.0149.66
5.0.50.0040.0118.58
5.0.40.0020.0168.52
5.0.30.0060.0178.42
5.0.20.0050.0108.41
5.0.10.0040.0108.40
5.0.00.0020.0208.39
4.4.90.0040.0077.64
4.4.80.0040.0107.62
4.4.70.0040.0077.63
4.4.60.0030.0107.63
4.4.50.0040.0097.63
4.4.40.0040.0127.60
4.4.30.0020.0097.63
4.4.20.0020.0097.67
4.4.10.0010.0147.67
4.4.00.0020.0207.63
4.3.110.0020.0097.58
4.3.100.0010.0167.58
4.3.90.0020.0117.56
4.3.80.0040.0147.54
4.3.70.0030.0087.56
4.3.60.0020.0097.56
4.3.50.0020.0097.56
4.3.40.0020.0137.51
4.3.30.0010.0096.90
4.3.20.0010.0096.88
4.3.10.0010.0096.87
4.3.00.0030.01120.72

preferences:
39.66 ms | 401 KiB | 5 Q