3v4l.org

run code in 300+ PHP versions simultaneously
<?php class State { protected $foo; protected $bar; public function getFoo() { return $this->foo; } public function getBar() { return $this->bar; } public final function setFoo($foo) { $this->foo = $foo; } public final function setBar($bar) { $this->bar = $bar; } public final function transaction(callable $function) { $proxy = new StateProxy($this); if (call_user_func($function, $proxy)) { $proxy->commit(); } unset($proxy); } } class StateProxy extends State { protected $state; public function __construct(State $state) { $this->state = $state; } public function getFoo() { return parent::getFoo() ? : $this->state->getFoo(); } public function getBar() { return parent::getBar() ? : $this->state->getBar(); } public function commit() { $this->state->foo = $this->foo; $this->state->bar = $this->bar; } } $state = new State(); $state->setFoo('abc'); $state->setBar('123'); var_dump($state); $state->transaction(function(StateProxy $proxy) { $proxy->setFoo('def'); $proxy->setBar('456'); return true; }); var_dump($state); $state->transaction(function(StateProxy $proxy) { $proxy->setFoo('ghi'); $proxy->setBar('789'); return false; }); var_dump($state); $state = new State(); $state->setFoo('abc'); $state->setBar('123'); $state->transaction(function(StateProxy $proxy) { $proxy->transaction(function(StateProxy $proxy) { $proxy->transaction(function(StateProxy $proxy) { $proxy->transaction(function(StateProxy $proxy) { $proxy->setFoo('def'); $proxy->setBar('456'); return false; }); $proxy->transaction(function(StateProxy $proxy) { $proxy->setFoo('ghi'); $proxy->setBar('789'); return true; }); return true; }); $proxy->transaction(function(StateProxy $proxy) { $proxy->setFoo('jkl'); $proxy->setBar('012'); return false; }); return true; }); return true; }); var_dump($state);

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.0040.01216.49
8.3.60.0000.01516.73
8.3.50.0150.00421.99
8.3.40.0120.00618.92
8.3.30.0040.01119.04
8.3.20.0040.01120.30
8.3.10.0040.00423.58
8.3.00.0080.00022.52
8.2.190.0040.01216.58
8.2.180.0160.00318.21
8.2.170.0120.00322.96
8.2.160.0070.00722.17
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0040.00420.52
8.2.110.0090.00022.27
8.2.100.0060.00617.84
8.2.90.0040.00419.23
8.2.80.0000.00818.03
8.2.70.0070.00317.48
8.2.60.0000.00817.93
8.2.50.0000.00818.07
8.2.40.0110.00018.28
8.2.30.0060.00317.98
8.2.20.0040.00417.68
8.2.10.0040.00417.69
8.2.00.0040.00417.75
8.1.280.0090.01225.92
8.1.270.0000.00923.87
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00624.01
8.1.230.0000.01118.97
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0060.00317.48
8.1.190.0050.00317.40
8.1.180.0050.00318.10
8.1.170.0030.00618.72
8.1.160.0080.00022.00
8.1.150.0000.00718.59
8.1.140.0040.00417.49
8.1.130.0040.00417.79
8.1.120.0030.00717.52
8.1.110.0000.00817.46
8.1.100.0040.00417.52
8.1.90.0000.00817.49
8.1.80.0070.00017.51
8.1.70.0040.00417.45
8.1.60.0080.00017.62
8.1.50.0030.00617.54
8.1.40.0000.00717.62
8.1.30.0030.00617.57
8.1.20.0000.00817.59
8.1.10.0030.00617.46
8.1.00.0000.00817.53
8.0.300.0040.00418.77
8.0.290.0050.00317.15
8.0.280.0070.00018.46
8.0.270.0030.00317.29
8.0.260.0030.00316.90
8.0.250.0030.00317.00
8.0.240.0070.00016.93
8.0.230.0000.00716.94
8.0.220.0030.00316.89
8.0.210.0070.00016.79
8.0.200.0000.00817.04
8.0.190.0040.00416.94
8.0.180.0000.00816.94
8.0.170.0040.00416.94
8.0.160.0040.00417.05
8.0.150.0030.00616.88
8.0.140.0000.00716.84
8.0.130.0000.00613.40
8.0.120.0040.00416.95
8.0.110.0040.00416.87
8.0.100.0070.00016.86
8.0.90.0070.00016.90
8.0.80.0060.00916.97
8.0.70.0030.00616.95
8.0.60.0000.00816.93
8.0.50.0000.00717.05
8.0.30.0080.01117.13
8.0.20.0150.00617.40
8.0.10.0050.00317.09
8.0.00.0130.00616.68
7.4.330.0000.00515.03
7.4.320.0030.00316.54
7.4.300.0030.00316.64
7.4.290.0040.00416.59
7.4.280.0080.00016.66
7.4.270.0030.00316.46
7.4.260.0070.00016.57
7.4.250.0000.00716.50
7.4.240.0050.00216.54
7.4.230.0070.00016.71
7.4.220.0070.01116.66
7.4.210.0040.01216.56
7.4.200.0000.00716.57
7.4.190.0000.00716.69
7.4.160.0060.01216.42
7.4.150.0000.02017.40
7.4.140.0090.01017.86
7.4.130.0100.01216.55
7.4.120.0110.00716.56
7.4.110.0100.00716.56
7.4.100.0110.01116.45
7.4.90.0060.01416.51
7.4.80.0070.01616.43
7.4.70.0040.01516.55
7.4.60.0100.00716.45
7.4.50.0030.00616.25
7.4.40.0000.01222.77
7.4.30.0060.01116.57
7.4.10.0100.01014.96
7.4.00.0050.01214.92
7.3.330.0050.00013.20
7.3.320.0060.00013.34
7.3.310.0020.00516.31
7.3.300.0000.00716.18
7.3.290.0050.00916.34
7.3.280.0100.00816.29
7.3.270.0070.01717.40
7.3.260.0110.00816.60
7.3.250.0120.00616.45
7.3.240.0140.01016.36
7.3.230.0070.01116.39
7.3.210.0130.00716.62
7.3.200.0070.01119.39
7.3.190.0070.01016.53
7.3.180.0070.01016.51
7.3.170.0030.01716.32
7.3.160.0130.00316.38
7.3.130.0060.01114.65
7.3.120.0030.01414.91
7.3.110.0100.00714.66
7.3.100.0100.00314.49
7.3.90.0090.00614.85
7.3.80.0070.01114.80
7.3.70.0080.00814.68
7.3.60.0040.01115.00
7.3.50.0070.00314.73
7.3.40.0060.00314.96
7.3.30.0060.00614.67
7.3.20.0080.00916.80
7.3.10.0080.00716.67
7.3.00.0080.00316.60
7.2.330.0000.01716.85
7.2.320.0030.01516.79
7.2.310.0130.00616.39
7.2.300.0090.00616.48
7.2.290.0070.01016.38
7.2.260.0090.00914.91
7.2.250.0090.00915.23
7.2.240.0030.00615.22
7.2.230.0080.00415.22
7.2.220.0000.01115.18
7.2.210.0060.00915.16
7.2.200.0060.00915.18
7.2.190.0060.00915.02
7.2.180.0070.00714.89
7.2.170.0110.00415.19
7.2.160.0030.01015.05
7.2.150.0070.01016.96
7.2.140.0100.01016.76
7.2.130.0090.00617.00
7.2.120.0040.00716.88
7.2.110.0070.00716.95
7.2.100.0030.01216.85
7.2.90.0020.01117.01
7.2.80.0030.01116.77
7.2.70.0080.00716.81
7.2.60.0070.00516.91
7.2.50.0080.00616.88
7.2.40.0050.00916.70
7.2.30.0050.00816.71
7.2.20.0080.00616.75
7.2.10.0080.00716.88
7.2.00.0060.00716.83
7.1.330.0030.01215.56
7.1.320.0130.00315.92
7.1.310.0030.00915.73
7.1.300.0000.01115.82
7.1.290.0040.01115.95
7.1.280.0070.00715.84
7.1.270.0040.01115.79
7.1.260.0030.00915.71
7.1.250.0040.00815.66
7.1.240.0070.00415.86
7.1.230.0060.00315.91
7.1.220.0030.01015.77
7.1.210.0030.01015.61
7.1.200.0060.00815.75
7.1.190.0090.00615.87
7.1.180.0090.00015.94
7.1.170.0090.00315.84
7.1.160.0040.00816.02
7.1.150.0090.00615.72
7.1.140.0070.00715.82
7.1.130.0060.00915.69
7.1.120.0040.00815.69
7.1.110.0040.00715.73
7.1.100.0000.01415.82
7.1.90.0070.00415.79
7.1.80.0060.00315.71
7.1.70.0030.00916.34
7.1.60.0080.01017.55
7.1.50.0080.00816.22
7.1.40.0110.00015.58
7.1.30.0000.00815.70
7.1.20.0100.00315.72
7.1.10.0060.00315.64
7.1.00.0040.04219.11
7.0.330.0150.00015.47
7.0.320.0070.00715.59
7.0.310.0100.00315.47
7.0.300.0040.00715.40
7.0.290.0040.00715.35
7.0.280.0000.01415.45
7.0.270.0070.00715.16
7.0.260.0040.00815.46
7.0.250.0030.00915.57
7.0.240.0000.01515.37
7.0.230.0060.00315.50
7.0.220.0000.01515.49
7.0.210.0000.01615.52
7.0.200.0060.00616.08
7.0.190.0050.00315.48
7.0.180.0030.00615.50
7.0.170.0000.01115.46
7.0.160.0060.00615.29
7.0.150.0100.00615.49
7.0.140.0020.04518.76
7.0.130.0070.00715.50
7.0.120.0070.00715.31
7.0.110.0090.00615.20
7.0.100.0170.04217.70
7.0.90.0080.02817.62
7.0.80.0080.04517.79
7.0.70.0080.02917.67
7.0.60.0000.04417.82
7.0.50.0110.02018.03
7.0.40.0070.04716.76
7.0.30.0040.02716.80
7.0.20.0100.04116.82
7.0.10.0110.03616.87
7.0.00.0100.04116.82
5.6.400.0060.01314.59
5.6.390.0030.01014.17
5.6.380.0070.01014.32
5.6.370.0080.00914.60
5.6.360.0030.01014.55
5.6.350.0070.00714.45
5.6.340.0060.00914.48
5.6.330.0070.00714.01
5.6.320.0060.00914.28
5.6.310.0030.00614.50
5.6.300.0050.00514.28
5.6.290.0090.00314.43
5.6.280.0080.00414.71
5.6.270.0000.00914.40
5.6.260.0030.01014.46
5.6.250.0050.03017.59
5.6.240.0090.02617.64
5.6.230.0080.02517.60
5.6.220.0110.03817.52
5.6.210.0090.02717.68
5.6.200.0080.03317.71
5.6.190.0080.02317.66
5.6.180.0050.02417.87
5.6.170.0070.02317.89
5.6.160.0070.04217.91
5.6.150.0140.03717.80
5.6.140.0080.02317.70
5.6.130.0130.04117.88
5.6.120.0140.04517.61
5.6.110.0100.03817.77
5.6.100.0070.04217.89
5.6.90.0050.04717.70
5.6.80.0080.03617.38
5.6.70.0020.04617.33
5.6.60.0050.04517.37
5.6.50.0110.03017.48
5.6.40.0080.03917.26
5.6.30.0080.03717.37
5.6.20.0010.04417.42
5.6.10.0030.04717.54
5.6.00.0080.02317.45
5.5.380.0020.04817.36
5.5.370.0080.05217.52
5.5.360.0030.03817.38
5.5.350.0050.02717.32
5.5.340.0120.02517.69
5.5.330.0000.04017.62
5.5.320.0090.03217.51
5.5.310.0030.03017.48
5.5.300.0080.02717.63
5.5.290.0050.05017.56
5.5.280.0100.02517.62
5.5.270.0060.04117.48
5.5.260.0100.04117.68
5.5.250.0080.04017.37
5.5.240.0070.04517.27
5.5.230.0030.04317.32
5.5.220.0090.04217.14
5.5.210.0100.03817.25
5.5.200.0020.04617.14
5.5.190.0100.04217.27
5.5.180.0130.03717.15
5.5.170.0040.00714.28
5.5.160.0080.03917.25
5.5.150.0100.03817.15
5.5.140.0070.04617.30
5.5.130.0100.03817.16
5.5.120.0140.03617.31
5.5.110.0040.04417.21
5.5.100.0030.03917.17
5.5.90.0030.03017.25
5.5.80.0080.03917.06
5.5.70.0040.04017.09
5.5.60.0020.03417.06
5.5.50.0040.02317.21
5.5.40.0070.02017.26
5.5.30.0110.02217.11
5.5.20.0030.02717.08
5.5.10.0040.02617.28
5.5.00.0070.02417.00
5.4.450.0050.04115.61
5.4.440.0060.03415.54
5.4.430.0020.04415.65
5.4.420.0030.04115.69
5.4.410.0030.04415.55
5.4.400.0030.04315.51
5.4.390.0040.04215.40
5.4.380.0020.04015.55
5.4.370.0030.04315.49
5.4.360.0050.03715.47
5.4.350.0080.03815.38
5.4.340.0100.02515.45
5.4.330.0040.00711.86
5.4.320.0090.03815.45
5.4.310.0050.04015.38
5.4.300.0040.03115.44
5.4.290.0050.04115.46
5.4.280.0060.01915.51
5.4.270.0050.04115.34
5.4.260.0040.02315.38
5.4.250.0100.02715.49
5.4.240.0060.04015.35
5.4.230.0100.03215.44
5.4.220.0050.04115.49
5.4.210.0070.03215.51
5.4.200.0060.03915.49
5.4.190.0050.02915.49
5.4.180.0100.04015.51
5.4.170.0020.02615.53
5.4.160.0020.02015.51
5.4.150.0050.02215.48
5.4.140.0070.01714.17
5.4.130.0020.04114.17
5.4.120.0070.03714.20
5.4.110.0050.03614.13
5.4.100.0030.03214.17
5.4.90.0020.02114.15
5.4.80.0050.01914.12
5.4.70.0000.03514.09
5.4.60.0050.04014.20
5.4.50.0050.03514.13
5.4.40.0030.03814.15
5.4.30.0060.01614.19
5.4.20.0000.02914.15
5.4.10.0030.02214.08
5.4.00.0090.03913.85
5.3.290.0100.03513.26
5.3.280.0110.03813.25
5.3.270.0040.04013.29
5.3.260.0050.03113.24
5.3.250.0070.04013.23
5.3.240.0040.03513.29
5.3.230.0040.02413.23
5.3.220.0070.02513.20
5.3.210.0080.03813.21
5.3.200.0050.03613.21
5.3.190.0080.02513.21
5.3.180.0000.02313.27
5.3.170.0080.03513.20
5.3.160.0070.03813.29
5.3.150.0060.03213.22
5.3.140.0000.02413.26
5.3.130.0090.03113.28
5.3.120.0100.03813.28
5.3.110.0060.02913.20
5.3.100.0030.03813.01
5.3.90.0050.03612.96
5.3.80.0040.04213.03
5.3.70.0090.03612.95
5.3.60.0030.03412.95
5.3.50.0090.03412.96
5.3.40.0030.04112.89
5.3.30.0050.03912.86
5.3.20.0020.03712.84
5.3.10.0030.03412.78
5.3.00.0080.01712.74
5.2.170.0070.03711.27
5.2.160.0030.04011.09
5.2.150.0000.03711.02
5.2.140.0100.04711.05
5.2.130.0030.03711.00
5.2.120.0070.04011.17
5.2.110.0070.05711.17
5.2.100.0070.06311.13
5.2.90.0130.04711.13
5.2.80.0100.04011.02
5.2.70.0000.04311.16
5.2.60.0070.05710.93
5.2.50.0000.03311.07
5.2.40.0100.06010.92
5.2.30.0030.03310.90
5.2.20.0000.05310.93
5.2.10.0030.06310.89
5.2.00.0070.05710.59
5.1.60.0070.04310.07
5.1.50.0030.05010.10
5.1.40.0030.0509.84
5.1.30.0030.03010.46
5.1.20.0030.05710.48
5.1.10.0070.0509.94
5.1.00.0070.05710.09
5.0.50.0000.0408.45
5.0.40.0030.0208.28
5.0.30.0070.0578.32
5.0.20.0070.0378.25
5.0.10.0070.0238.25
5.0.00.0100.0438.26
4.4.90.0000.0278.25
4.4.80.0030.0338.25
4.4.70.0100.0308.25
4.4.60.0000.0208.25
4.4.50.0000.0408.25
4.4.40.0030.0278.25
4.4.30.0000.0238.25
4.4.20.0000.0378.25
4.4.10.0000.0378.25
4.4.00.0000.0308.25
4.3.110.0000.0208.25
4.3.100.0070.0308.25
4.3.90.0030.0278.25
4.3.80.0030.0278.25
4.3.70.0030.0238.25
4.3.60.0000.0378.25
4.3.50.0070.0308.25
4.3.40.0000.0278.25
4.3.30.0070.0138.25
4.3.20.0000.0338.25
4.3.10.0030.0308.25
4.3.00.0000.0308.25

preferences:
43.3 ms | 401 KiB | 5 Q