3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar = 'baz'; public function getBar() { return $this->bar; } } // http://3v4l.org/pc6lo#v540 class ClassicLazyFoo extends Foo { private $initialized = false; public function getBar() { $this->init(); return parent::getBar(); } private function init() { if ($this->initialized) { return; } \Closure::bind(function() { $this->bar = 'Loaded from DB!'; }, $this, get_parent_class($this))->__invoke(); } } // look ma: no method overrides! class LazyPropertyLazyFoo extends Foo { public function __construct() { \Closure::bind(function() { unset($this->bar); }, $this, get_parent_class($this))->__invoke(); } // note that other magic accessors also need to be created for full functional completeness public function __get($name) { \Closure::bind(function() { $this->bar = 'Loaded from DB!'; }, $this, get_parent_class($this))->__invoke(); return $this->$name; } } var_dump((new ClassicLazyFoo())->getBar()); var_dump((new LazyPropertyLazyFoo())->getBar());

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.55
8.3.50.0140.00521.96
8.3.40.0120.00318.79
8.3.30.0000.01419.23
8.3.20.0080.00020.38
8.3.10.0080.00020.71
8.3.00.0080.00019.13
8.2.180.0140.00018.16
8.2.170.0120.00322.96
8.2.160.0130.00320.36
8.2.150.0030.00624.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0030.00622.02
8.2.110.0080.00022.12
8.2.100.0120.00017.84
8.2.90.0000.00819.17
8.2.80.0050.00317.97
8.2.70.0090.00017.25
8.2.60.0040.00417.80
8.2.50.0080.00018.07
8.2.40.0000.00818.28
8.2.30.0040.00419.20
8.2.20.0040.00417.77
8.2.10.0000.00717.98
8.2.00.0040.00417.84
8.1.280.0000.01425.92
8.1.270.0040.00422.00
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0030.00722.23
8.1.230.0040.00719.08
8.1.220.0030.00617.74
8.1.210.0080.00418.77
8.1.200.0000.00917.47
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0070.00418.62
8.1.160.0000.00822.03
8.1.150.0040.00418.82
8.1.140.0050.00317.42
8.1.130.0030.00317.75
8.1.120.0070.00017.44
8.1.110.0000.00717.48
8.1.100.0000.00717.48
8.1.90.0030.00317.50
8.1.80.0040.00717.45
8.1.70.0000.00717.44
8.1.60.0030.00517.54
8.1.50.0040.00717.54
8.1.40.0000.00717.56
8.1.30.0060.00317.63
8.1.20.0000.00717.66
8.1.10.0030.00517.49
8.1.00.0080.00317.49
8.0.300.0060.00318.77
8.0.290.0040.00416.75
8.0.280.0000.00718.45
8.0.270.0000.00717.27
8.0.260.0060.00017.19
8.0.250.0000.00717.06
8.0.240.0050.00317.01
8.0.230.0030.00316.88
8.0.220.0040.00416.97
8.0.210.0030.00316.98
8.0.200.0000.00817.03
8.0.190.0040.00416.89
8.0.180.0000.00716.89
8.0.170.0000.00716.89
8.0.160.0080.00017.01
8.0.150.0040.00416.93
8.0.140.0000.00816.80
8.0.130.0000.00513.44
8.0.120.0080.00016.88
8.0.110.0030.00516.92
8.0.100.0030.00516.99
8.0.90.0000.00816.81
8.0.80.0060.01616.86
8.0.70.0040.00416.85
8.0.60.0030.00316.99
8.0.50.0040.00416.75
8.0.30.0090.01217.13
8.0.20.0090.01117.40
8.0.10.0000.00817.10
8.0.00.0090.01116.75
7.4.330.0030.00315.04
7.4.320.0030.00316.61
7.4.300.0000.00716.54
7.4.290.0000.00716.66
7.4.280.0040.00416.61
7.4.270.0040.00416.42
7.4.260.0030.00316.50
7.4.250.0030.00516.52
7.4.240.0000.00716.52
7.4.230.0040.00416.71
7.4.220.0140.01016.59
7.4.210.0080.00516.62
7.4.200.0000.00716.57
7.4.160.0060.00916.68
7.4.150.0110.00717.40
7.4.140.0140.00817.86
7.4.130.0070.01016.57
7.4.120.0130.00516.55
7.4.110.0140.00316.36
7.4.100.0140.00716.60
7.4.90.0070.01016.37
7.4.80.0100.01319.37
7.4.70.0100.00716.35
7.4.60.0070.01016.53
7.4.50.0030.00616.54
7.4.40.0140.00316.66
7.4.30.0030.01516.37
7.4.00.0120.00515.17
7.3.330.0000.00613.27
7.3.320.0050.00013.43
7.3.310.0000.00716.40
7.3.300.0070.00016.31
7.3.290.0090.00616.47
7.3.280.0100.00716.44
7.3.270.0070.01317.40
7.3.260.0160.00316.32
7.3.250.0090.00916.57
7.3.240.0120.01216.49
7.3.230.0130.00316.63
7.3.210.0070.01016.60
7.3.200.0030.01419.39
7.3.190.0170.00016.56
7.3.180.0170.00316.54
7.3.170.0100.01116.63
7.3.160.0170.00016.57
7.3.120.0090.00615.16
7.3.110.0090.00615.09
7.3.100.0000.01414.83
7.3.90.0070.00714.97
7.3.80.0070.00415.04
7.3.70.0090.00314.86
7.3.60.0090.00614.63
7.3.50.0070.00714.84
7.3.40.0130.00014.81
7.3.30.0040.01214.86
7.3.20.0070.00316.46
7.3.10.0030.01116.55
7.3.00.0100.00516.31
7.2.330.0140.00316.89
7.2.320.0100.00716.74
7.2.310.0150.01016.77
7.2.300.0000.01616.73
7.2.290.0110.01116.55
7.2.250.0030.01615.16
7.2.240.0040.01415.18
7.2.230.0030.00615.03
7.2.220.0000.01314.96
7.2.210.0060.00915.05
7.2.200.0030.00914.96
7.2.190.0060.00914.89
7.2.180.0140.00015.22
7.2.170.0090.00615.05
7.2.130.0100.00316.40
7.2.120.0130.00716.63
7.2.110.0100.00715.84
7.2.100.0120.00416.34
7.2.90.0130.00616.59
7.2.80.0130.00616.57
7.2.70.0210.00316.10
7.2.60.0160.00716.72
7.2.50.0080.00816.50
7.2.40.0220.00316.71
7.2.30.0130.01016.16
7.2.20.0210.00016.79
7.2.10.0160.00916.23
7.2.00.0130.01016.61
7.1.330.0070.00716.01
7.1.320.0120.00315.86
7.1.310.0040.01215.68
7.1.300.0060.00715.68
7.1.290.0070.00715.83
7.1.280.0030.01315.83
7.1.270.0030.01115.74
7.1.260.0000.01715.69
7.1.250.0070.01315.48
7.1.200.0030.00715.59
7.1.70.0030.00917.21
7.1.60.0110.01519.32
7.1.50.0090.01317.06
7.1.00.0030.07322.45
7.0.200.0000.00716.89
7.0.140.0100.06721.98
7.0.60.0000.04319.88
7.0.50.0030.06017.73
7.0.40.0070.06020.13
7.0.30.0400.04320.16
7.0.20.0100.04720.06
7.0.10.0130.08320.15
7.0.00.0100.07020.23
5.6.280.0030.07321.13
5.6.210.0100.06020.78
5.6.200.0070.03718.34
5.6.190.0000.04720.54
5.6.180.0570.06720.46
5.6.170.0270.08320.44
5.6.160.0100.07720.54
5.6.150.0030.04318.25
5.6.140.0030.05718.15
5.6.130.0030.07018.14
5.6.120.0030.06320.82
5.6.110.0070.07321.04
5.6.100.0100.07321.03
5.6.90.0170.05721.00
5.6.80.0030.04020.37
5.5.350.0200.07020.41
5.5.340.0030.07717.94
5.5.330.0000.04320.43
5.5.320.0400.07720.30
5.5.310.0330.07020.30
5.5.300.0030.04017.95
5.5.290.0070.08717.98
5.5.280.0130.08020.90
5.5.270.0100.08320.89
5.5.260.0100.08320.75
5.5.250.0130.07320.52
5.5.240.0070.08020.18
5.4.450.0930.03719.35
5.4.440.0900.07319.61
5.4.430.0900.04719.54
5.4.420.0670.00019.32
5.4.410.0800.00019.23
5.4.400.0770.00019.23
5.4.390.0770.00019.13
5.4.380.0430.07318.77
5.4.370.0470.07018.74
5.4.360.0470.06318.58
5.4.350.0300.05318.80
5.4.340.0370.04718.63
5.4.320.0040.03812.53
5.4.310.0040.04012.52
5.4.300.0080.03812.52
5.4.290.0090.03612.52
5.4.280.0050.03812.41
5.4.270.0060.03512.42
5.4.260.0070.03612.42
5.4.250.0050.03712.42
5.4.240.0060.03512.42
5.4.230.0050.03812.41
5.4.220.0070.03512.41
5.4.210.0060.03512.41
5.4.200.0050.04012.41
5.4.190.0110.03212.41
5.4.180.0080.03412.41
5.4.170.0060.03712.41
5.4.160.0070.03512.41
5.4.150.0080.03812.41
5.4.140.0070.04012.09
5.4.130.0060.03512.08
5.4.120.0030.03812.04
5.4.110.0060.03512.04
5.4.100.0100.03212.04
5.4.90.0070.03612.03
5.4.80.0050.03712.03
5.4.70.0030.05012.03
5.4.60.0060.04412.02
5.4.50.0070.03312.02
5.4.40.0050.03712.01
5.4.30.0040.03812.01
5.4.20.0060.03712.01
5.4.10.0030.04012.01
5.4.00.0080.03411.50
5.3.290.0060.04012.80
5.3.280.0090.03412.72
5.3.270.0080.03712.73
5.3.260.0050.03912.73
5.3.250.0060.03712.73
5.3.240.0040.03912.73
5.3.230.0050.03912.72
5.3.220.0050.03912.69
5.3.210.0080.04412.69
5.3.200.0060.03712.69
5.3.190.0070.03712.69
5.3.180.0040.03912.68
5.3.170.0080.03512.68
5.3.160.0040.05112.68
5.3.150.0090.04512.69
5.3.140.0040.05512.68
5.3.130.0070.04112.67
5.3.120.0050.04312.67
5.3.110.0060.04412.67
5.3.100.0050.03812.16
5.3.90.0060.04312.14
5.3.80.0060.03612.13
5.3.70.0080.03512.13
5.3.60.0080.03812.12
5.3.50.0090.03912.06
5.3.40.0030.04012.07
5.3.30.0110.04712.02
5.3.20.0120.04411.81
5.3.10.0100.04511.77
5.3.00.0140.04311.76
5.2.170.0060.0379.23
5.2.160.0080.0429.23
5.2.150.0050.0319.23
5.2.140.0090.0409.22
5.2.130.0080.0409.19
5.2.120.0050.0339.19
5.2.110.0030.0359.19
5.2.100.0090.0259.19
5.2.90.0010.0349.18
5.2.80.0040.0319.18
5.2.70.0070.0289.18
5.2.60.0050.0329.14
5.2.50.0050.0409.11
5.2.40.0080.0279.08
5.2.30.0040.0319.05
5.2.20.0030.0319.05
5.2.10.0030.0308.95
5.2.00.0050.0298.82
5.1.60.0040.0258.10
5.1.50.0040.0258.10
5.1.40.0040.0248.08
5.1.30.0040.0288.43
5.1.20.0040.0278.45
5.1.10.0040.0268.18
5.1.00.0070.0228.17
5.0.50.0050.0206.65
5.0.40.0030.0206.51
5.0.30.0060.0296.32
5.0.20.0020.0216.29
5.0.10.0060.0176.27
5.0.00.0070.0276.26
4.4.90.0010.0174.78
4.4.80.0040.0134.75
4.4.70.0050.0134.76
4.4.60.0020.0154.75
4.4.50.0020.0164.77
4.4.40.0040.0334.71
4.4.30.0040.0204.76
4.4.20.0020.0164.84
4.4.10.0030.0154.85
4.4.00.0030.0244.76
4.3.110.0020.0164.67
4.3.100.0050.0204.67
4.3.90.0030.0154.64
4.3.80.0030.0314.58
4.3.70.0010.0164.63
4.3.60.0010.0164.63
4.3.50.0060.0134.63
4.3.40.0050.0234.54
4.3.30.0010.0173.30
4.3.20.0030.0153.28
4.3.10.0020.0153.24
4.3.00.0030.01714.30

preferences:
46.02 ms | 401 KiB | 5 Q