3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ClassPrivateAccessor { /** @var \Closure */ private $contexGetter; /** @var \Closure */ private $contexSetter; /** @var \Closure */ private $contextSetterMany; public function __construct() { $this->contextGetter = function($fieldName) { return $this->$fieldName; }; $this->contextSetter = function($fieldName, $newValue) { $this->$fieldName = $newValue; }; $this->contextSetterMany = function(array $values) { foreach ($values as $field => $value) { $this->$field = $value; } }; } public function setContextForGetter($context) { $this->contexGetter = $this->contextGetter->bindTo($context, $context); } public function setContextForSetter($context) { $this->contexSetter = $this->contextSetter->bindTo($context, $context); } public function setContextForSetterMany($context) { $this->contexSetterMany = $this->contextSetterMany->bindTo($context, $context); } public function get($fieldName) { return $this->contexGetter->__invoke($fieldName); } public function set($fieldName, $newValue) { $this->contexSetter->__invoke($fieldName, $newValue); } public function setMany($values) { $this->contextSetterMany($values); } } $accessor = new ClassPrivateAccessor(); class Foo { private $test1; private $test2; private $test3; } $foo = new Foo(); $accessor->setContextForSetter($foo); $accessor->set('test1',10);

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.0120.00618.80
8.3.50.0120.00622.01
8.3.40.0030.01218.84
8.3.30.0110.00319.08
8.3.20.0030.00720.34
8.3.10.0040.00421.76
8.3.00.0050.00317.78
8.2.180.0100.01016.38
8.2.170.0040.01422.96
8.2.160.0070.00720.46
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0000.00720.98
8.2.110.0060.00322.07
8.2.100.0060.00618.03
8.2.90.0050.00520.87
8.2.80.0040.00417.97
8.2.70.0050.00317.38
8.2.60.0110.00018.04
8.2.50.0050.00518.07
8.2.40.0040.00419.82
8.2.30.0000.00718.09
8.2.20.0000.00717.72
8.2.10.0000.00718.11
8.2.00.0050.00317.65
8.1.280.0140.00025.92
8.1.270.0030.00623.83
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0100.01022.19
8.1.230.0080.00422.61
8.1.220.0000.00817.74
8.1.210.0000.00918.92
8.1.200.0040.00417.48
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0030.00518.66
8.1.160.0000.00722.03
8.1.150.0040.00419.00
8.1.140.0030.00617.36
8.1.130.0050.00317.84
8.1.120.0040.00417.38
8.1.110.0080.00017.52
8.1.100.0040.00417.38
8.1.90.0000.00717.31
8.1.80.0070.00017.35
8.1.70.0000.00717.38
8.1.60.0040.00417.60
8.1.50.0050.00317.52
8.1.40.0000.00917.52
8.1.30.0000.00917.50
8.1.20.0000.00717.60
8.1.10.0000.00717.48
8.1.00.0000.00917.47
8.0.300.0000.00819.93
8.0.290.0040.00416.63
8.0.280.0030.00518.50
8.0.270.0000.00717.26
8.0.260.0000.00617.34
8.0.250.0030.00316.99
8.0.240.0030.00317.00
8.0.230.0040.00416.89
8.0.220.0000.00616.91
8.0.210.0000.00716.90
8.0.200.0000.00716.96
8.0.190.0000.00716.89
8.0.180.0040.00417.02
8.0.170.0080.00016.97
8.0.160.0080.00016.86
8.0.150.0040.00416.81
8.0.140.0070.00016.84
8.0.130.0060.00013.32
8.0.120.0050.00316.79
8.0.110.0000.00716.83
8.0.100.0040.00416.76
8.0.90.0070.00016.74
8.0.80.0060.01616.87
8.0.70.0070.00016.90
8.0.60.0070.00016.78
8.0.50.0040.00416.97
8.0.30.0100.01016.92
8.0.20.0090.01117.40
8.0.10.0050.00217.00
8.0.00.0120.00816.79
7.4.330.0050.00015.00
7.4.320.0030.00316.64
7.4.300.0000.00616.52
7.4.290.0030.00316.52
7.4.280.0040.00416.51
7.4.270.0040.00416.66
7.4.260.0040.00716.50
7.4.250.0000.00716.39
7.4.240.0030.00516.46
7.4.230.0000.00716.66
7.4.220.0120.00616.65
7.4.210.0070.00716.71
7.4.200.0070.00016.50
7.4.160.0120.00316.47
7.4.150.0150.00617.40
7.4.140.0120.01017.86
7.4.130.0110.00516.50
7.4.120.0110.00616.42
7.4.110.0080.00816.65
7.4.100.0120.00616.51
7.4.90.0140.00316.58
7.4.80.0090.01119.39
7.4.70.0030.01416.45
7.4.60.0040.01616.59
7.4.50.0050.00316.44
7.4.40.0030.01316.53
7.4.30.0030.01316.61
7.4.10.0140.00515.13
7.4.00.0110.00414.79
7.3.330.0020.00213.39
7.3.320.0020.00213.34
7.3.310.0030.00316.38
7.3.300.0030.00316.30
7.3.290.0070.00716.34
7.3.280.0100.00716.40
7.3.270.0080.01117.40
7.3.260.0060.01216.36
7.3.250.0130.00716.51
7.3.240.0090.01216.67
7.3.230.0060.01116.68
7.3.210.0150.00316.50
7.3.200.0110.01019.39
7.3.190.0080.00916.71
7.3.180.0090.00916.69
7.3.170.0120.02116.39
7.3.160.0150.00616.64
7.3.130.0060.01114.76
7.3.120.0090.00814.86
7.3.110.0090.00715.02
7.3.100.0090.00515.07
7.3.90.0070.01014.80
7.3.80.0100.00414.88
7.3.70.0040.00714.71
7.3.60.0060.01014.95
7.3.50.0020.01014.71
7.3.40.0000.01114.59
7.3.30.0090.00514.62
7.3.20.0070.00716.63
7.3.10.0040.00716.67
7.3.00.0060.00616.60
7.2.330.0030.01516.76
7.2.320.0100.01316.49
7.2.310.0100.01316.74
7.2.300.0100.00716.79
7.2.290.0140.00316.38
7.2.260.0110.00815.26
7.2.250.0090.00915.05
7.2.240.0080.00614.93
7.2.230.0110.00514.99
7.2.220.0070.00715.07
7.2.210.0060.00515.03
7.2.200.0030.01014.96
7.2.190.0030.01014.95
7.2.180.0060.00814.95
7.2.170.0030.01115.02
7.2.160.0050.00715.14
7.2.150.0090.00516.73
7.2.140.0080.00716.85
7.2.130.0060.00616.79
7.2.120.0030.00916.95
7.2.110.0050.00716.84
7.2.100.0070.00616.85
7.2.90.0050.00817.10
7.2.80.0070.00816.84
7.2.70.0030.01116.93
7.2.60.0070.00716.92
7.2.50.0060.00716.88
7.2.40.0100.00416.84
7.2.30.0080.00616.95
7.2.20.0040.00917.01
7.2.10.0070.00416.89
7.2.00.0040.00917.58
7.1.330.0050.01015.56
7.1.320.0030.01015.87
7.1.310.0080.00515.82
7.1.300.0090.00615.81
7.1.290.0070.00415.94
7.1.280.0020.01015.88
7.1.270.0020.00915.67
7.1.260.0000.01215.69
7.1.250.0070.00715.71
7.1.240.0040.00415.72
7.1.230.0040.00815.61
7.1.220.0040.01215.51
7.1.210.0030.00615.80
7.1.200.0090.00715.70
7.1.190.0090.00215.72
7.1.180.0050.00715.55
7.1.170.0080.00515.64
7.1.160.0080.00315.87
7.1.150.0020.01115.73
7.1.140.0030.00915.73
7.1.130.0040.00815.70
7.1.120.0080.00315.85
7.1.110.0030.01015.86
7.1.100.0050.00716.53
7.1.90.0090.00515.83
7.1.80.0080.00515.61
7.1.70.0040.00616.02
7.1.60.0090.00716.96
7.1.50.0070.00516.23
7.1.40.0050.01015.92
7.1.30.0050.00615.63
7.1.20.0090.00515.70
7.1.10.0050.01015.60
7.1.00.0050.02918.05
7.0.330.0020.01115.13
7.0.320.0060.01015.32
7.0.310.0070.00915.29
7.0.300.0020.01215.36
7.0.290.0050.00915.29
7.0.280.0040.00915.35
7.0.270.0040.00915.16
7.0.260.0060.00715.37
7.0.250.0050.00915.27
7.0.240.0080.00815.46
7.0.230.0090.00515.25
7.0.220.0050.00815.41
7.0.210.0070.00815.37
7.0.200.0050.00615.68
7.0.190.0030.00715.39
7.0.180.0080.00515.51
7.0.170.0060.00415.38
7.0.160.0040.00715.51
7.0.150.0030.01115.32
7.0.140.0020.03117.60
7.0.130.0030.00915.27
7.0.120.0080.00315.52
7.0.110.0040.01215.50
7.0.100.0080.00815.42
7.0.90.0040.00915.28
7.0.80.0070.00815.30
7.0.70.0070.00515.45
7.0.60.0070.03116.93
7.0.50.0080.02916.27
7.0.40.0030.02915.70
7.0.30.0110.02015.70
7.0.20.0100.02315.64
7.0.10.0060.01915.57
7.0.00.0060.02115.67
5.6.400.0030.00914.38
5.6.390.0040.00814.63
5.6.380.0040.00814.41
5.6.370.0110.00514.48
5.6.360.0050.00914.32
5.6.350.0050.00514.40
5.6.340.0030.01014.32
5.6.330.0070.00714.50
5.6.320.0040.00714.22
5.6.310.0030.00814.33
5.6.300.0060.00914.39
5.6.290.0020.01114.31
5.6.280.0050.02816.62
5.6.270.0100.00314.26
5.6.260.0090.00614.62
5.6.250.0040.01314.52
5.6.240.0020.01014.31
5.6.230.0050.00814.62
5.6.220.0060.00614.52
5.6.210.0070.03616.43
5.6.200.0040.02415.65
5.6.190.0040.03516.53
5.6.180.0150.02816.54
5.6.170.0170.02616.34
5.6.160.0060.02016.44
5.6.150.0040.03215.82
5.6.140.0030.02315.55
5.6.130.0040.02515.64
5.6.120.0060.02816.58
5.6.110.0040.02516.58
5.6.100.0040.01916.64
5.6.90.0100.03216.72
5.6.80.0060.03116.43
5.6.70.0070.00714.30
5.6.60.0130.00214.33
5.6.50.0030.01014.15
5.6.40.0030.01114.18
5.6.30.0050.00714.31
5.6.20.0050.00714.43
5.6.10.0040.01014.32
5.6.00.0040.00614.34
5.5.380.0060.00914.63
5.5.370.0030.00914.38
5.5.360.0070.00814.12
5.5.350.0060.01716.43
5.5.340.0070.02815.49
5.5.330.0060.01816.34
5.5.320.0040.03316.27
5.5.310.0120.02316.50
5.5.300.0050.01815.42
5.5.290.0060.01815.66
5.5.280.0070.02616.40
5.5.270.0030.02616.49
5.5.260.0060.03116.57
5.5.250.0060.01716.27
5.5.240.0110.02916.25
5.5.230.0060.00714.47
5.5.220.0030.00914.14
5.5.210.0040.00914.32
5.5.200.0040.01114.22
5.5.190.0070.00614.12
5.5.180.0040.00914.38
5.5.170.0050.00714.18
5.5.160.0020.00814.08
5.5.150.0030.00914.14
5.5.140.0060.00814.06
5.5.130.0080.00614.13
5.5.120.0030.01014.10
5.5.110.0070.00714.38
5.5.100.0080.00414.10
5.5.90.0080.00514.41
5.5.80.0090.00314.30
5.5.70.0060.00614.21
5.5.60.0040.00714.21
5.5.50.0050.00614.43
5.5.40.0020.01314.27
5.5.30.0050.00814.03
5.5.20.0050.00614.08
5.5.10.0070.00814.32
5.5.00.0050.00714.15
5.4.450.0250.01914.22
5.4.440.0120.02014.37
5.4.430.0060.01914.28
5.4.420.0180.02014.34
5.4.410.0120.01714.22
5.4.400.0160.01714.19
5.4.390.0080.01914.15
5.4.380.0160.02113.97
5.4.370.0130.02513.96
5.4.360.0120.03114.04
5.4.350.0210.02014.04
5.4.340.0180.03013.92
5.4.330.0050.00311.72
5.4.320.0010.01712.01
5.4.310.0030.02011.95
5.4.300.0060.01612.05
5.4.290.0050.01611.94
5.4.280.0030.01911.85
5.4.270.0040.01811.84
5.4.260.0040.01611.91
5.4.250.0040.01911.84
5.4.240.0050.01412.00
5.4.230.0040.01811.93
5.4.220.0060.01411.92
5.4.210.0050.01611.92
5.4.200.0070.01411.87
5.4.190.0050.01511.83
5.4.180.0040.01611.83
5.4.170.0030.01711.93
5.4.160.0060.01711.92
5.4.150.0040.01711.95
5.4.140.0040.01811.84
5.4.130.0050.01411.81
5.4.120.0030.01611.84
5.4.110.0020.02011.81
5.4.100.0030.01711.80
5.4.90.0030.01811.87
5.4.80.0030.01911.85
5.4.70.0040.01511.83
5.4.60.0060.01411.89
5.4.50.0060.02111.78
5.4.40.0080.01311.74
5.4.30.0040.01511.71
5.4.20.0040.01511.71
5.4.10.0020.01811.84
5.4.00.0080.01211.56
5.3.290.0030.01611.98
5.3.280.0060.01411.95
5.3.270.0070.01611.95
5.3.260.0070.01611.93
5.3.250.0060.01611.95
5.3.240.0040.01711.89
5.3.230.0040.01911.92
5.3.220.0070.01611.86
5.3.210.0040.01711.87
5.3.200.0060.01611.80
5.3.190.0060.01511.88
5.3.180.0040.02311.86
5.3.170.0030.01911.90
5.3.160.0060.02011.84
5.3.150.0030.01911.84
5.3.140.0040.01911.91
5.3.130.0040.01511.89
5.3.120.0050.01811.90
5.3.110.0060.01511.89
5.3.100.0060.01611.70
5.3.90.0030.01611.68
5.3.80.0030.01811.68
5.3.70.0040.01611.61
5.3.60.0040.01811.68
5.3.50.0060.01311.67
5.3.40.0030.01911.68
5.3.30.0040.01511.61
5.3.20.0040.01711.58
5.3.10.0030.01511.48
5.3.00.0030.01811.52
5.2.170.0060.0289.22
5.2.160.0030.0309.22
5.2.150.0040.0349.22
5.2.140.0050.0339.21
5.2.130.0070.0269.18
5.2.120.0080.0339.18
5.2.110.0060.0299.18
5.2.100.0050.0289.19
5.2.90.0070.0349.18
5.2.80.0030.0359.17
5.2.70.0040.0309.18
5.2.60.0070.0319.13
5.2.50.0080.0299.10
5.2.40.0040.0339.07
5.2.30.0050.0419.05
5.2.20.0080.0369.04
5.2.10.0060.0288.95
5.2.00.0040.0318.82
5.1.60.0040.0308.09
5.1.50.0030.0268.09
5.1.40.0080.0228.07
5.1.30.0040.0278.42
5.1.20.0040.0318.44
5.1.10.0040.0348.17
5.1.00.0020.0288.16
5.0.50.0070.0246.65
5.0.40.0050.0226.50
5.0.30.0070.0326.31
5.0.20.0030.0206.28
5.0.10.0030.0206.26
5.0.00.0030.0376.25
4.4.90.0030.0154.78
4.4.80.0020.0174.75
4.4.70.0030.0154.75
4.4.60.0030.0154.76
4.4.50.0040.0144.77
4.4.40.0030.0254.70
4.4.30.0010.0174.76
4.4.20.0030.0154.84
4.4.10.0040.0164.85
4.4.00.0030.0314.76
4.3.110.0050.0154.67
4.3.100.0050.0184.67
4.3.90.0070.0134.63
4.3.80.0050.0234.59
4.3.70.0030.0174.63
4.3.60.0020.0164.63
4.3.50.0020.0164.63
4.3.40.0040.0244.54
4.3.30.0020.0163.30
4.3.20.0020.0163.28
4.3.10.0030.0203.24
4.3.00.0070.01715.29

preferences:
41.61 ms | 401 KiB | 5 Q