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); // transaction succeeds, state changes $state->transaction(function(StateProxy $proxy) { $proxy->setFoo('def'); $proxy->setBar('456'); return true; }); var_dump($state); // transaction fails, state remains unchanged $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; }); // this'll be the one to succeed \/ $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.60.0120.00316.50
8.3.50.0120.00722.18
8.3.40.0120.00318.84
8.3.30.0110.00419.09
8.3.20.0070.00020.39
8.3.10.0080.00023.61
8.3.00.0060.00319.00
8.2.180.0040.01118.54
8.2.170.0070.00722.96
8.2.160.0110.00420.58
8.2.150.0030.00524.18
8.2.140.0060.00324.66
8.2.130.0150.00326.16
8.2.120.0050.00322.05
8.2.110.0110.00022.25
8.2.100.0040.00817.48
8.2.90.0000.00819.09
8.2.80.0000.00818.03
8.2.70.0050.00317.50
8.2.60.0090.00017.93
8.2.50.0040.00418.07
8.2.40.0000.00818.28
8.2.30.0050.00218.18
8.2.20.0000.00817.63
8.2.10.0060.00317.62
8.2.00.0000.00817.79
8.1.280.0140.00025.92
8.1.270.0000.00823.84
8.1.260.0030.00626.35
8.1.250.0070.00028.09
8.1.240.0060.00323.83
8.1.230.0070.00319.06
8.1.220.0030.00617.74
8.1.210.0000.00818.77
8.1.200.0030.00717.48
8.1.190.0000.00817.53
8.1.180.0000.00818.10
8.1.170.0040.00418.71
8.1.160.0070.00021.96
8.1.150.0040.00418.58
8.1.140.0000.00717.51
8.1.130.0080.00017.80
8.1.120.0000.00717.56
8.1.110.0000.00817.48
8.1.100.0070.00317.53
8.1.90.0000.00717.52
8.1.80.0000.00717.39
8.1.70.0000.00717.35
8.1.60.0000.00817.63
8.1.50.0000.00917.58
8.1.40.0040.00417.58
8.1.30.0040.00417.64
8.1.20.0080.00017.70
8.1.10.0080.00017.63
8.1.00.0120.00017.61
8.0.300.0070.00018.77
8.0.290.0040.00417.05
8.0.280.0070.00018.40
8.0.270.0000.00717.19
8.0.260.0000.00816.83
8.0.250.0000.00716.95
8.0.240.0000.00716.88
8.0.230.0040.00416.93
8.0.220.0030.00316.93
8.0.210.0050.00316.93
8.0.200.0070.00016.91
8.0.190.0030.00516.94
8.0.180.0080.00317.01
8.0.170.0040.00417.01
8.0.160.0000.00816.96
8.0.150.0020.00516.83
8.0.140.0040.00416.98
8.0.130.0060.00013.50
8.0.120.0040.00416.94
8.0.110.0050.00316.95
8.0.100.0040.00416.86
8.0.90.0070.00016.89
8.0.80.0090.00616.96
8.0.70.0000.00816.84
8.0.60.0000.00716.87
8.0.50.0000.00816.80
8.0.30.0090.01317.20
8.0.20.0170.00617.40
8.0.10.0000.00816.95
8.0.00.0110.00816.71
7.4.330.0030.00315.15
7.4.320.0070.00016.52
7.4.300.0000.00616.61
7.4.290.0070.00016.58
7.4.280.0000.00716.66
7.4.270.0000.00816.56
7.4.260.0030.00316.52
7.4.250.0040.00416.59
7.4.240.0030.00316.64
7.4.230.0030.00316.53
7.4.220.0120.00616.66
7.4.210.0060.00816.58
7.4.200.0000.00716.74
7.4.190.0040.00416.61
7.4.160.0120.00416.54
7.4.150.0120.00617.40
7.4.140.0070.01217.86
7.4.130.0080.00916.47
7.4.120.0100.00716.55
7.4.110.0040.01316.38
7.4.100.0070.01116.51
7.4.90.0120.01216.44
7.4.80.0030.01419.39
7.4.70.0140.00316.61
7.4.60.0080.00816.63
7.4.50.0000.00616.45
7.4.40.0040.01122.77
7.4.30.0110.00716.40
7.4.10.0030.01214.79
7.4.00.0040.01114.92
7.3.330.0060.00013.34
7.3.320.0000.00513.20
7.3.310.0060.00016.31
7.3.300.0000.00816.20
7.3.290.0090.00616.35
7.3.280.0100.00716.32
7.3.270.0130.00617.40
7.3.260.0030.01516.30
7.3.250.0070.01116.34
7.3.240.0130.00616.28
7.3.230.0120.01116.39
7.3.210.0070.01016.34
7.3.200.0130.00619.39
7.3.190.0150.00916.46
7.3.180.0100.00716.52
7.3.170.0060.01516.60
7.3.160.0060.00916.44
7.3.130.0040.01214.54
7.3.120.0060.00914.96
7.3.110.0070.01114.46
7.3.100.0000.01614.85
7.3.90.0070.01014.72
7.3.80.0070.01014.71
7.3.70.0030.00915.04
7.3.60.0070.00714.68
7.3.50.0080.00414.61
7.3.40.0030.01214.80
7.3.30.0000.01214.63
7.3.20.0030.01016.75
7.3.10.0080.00316.67
7.3.00.0040.01116.55
7.2.330.0110.00716.51
7.2.320.0130.01016.66
7.2.310.0120.00616.55
7.2.300.0110.00716.74
7.2.290.0060.01716.57
7.2.260.0150.00615.36
7.2.250.0060.00914.88
7.2.240.0140.00315.11
7.2.230.0060.00915.27
7.2.220.0130.00615.09
7.2.210.0030.01314.80
7.2.200.0100.00314.88
7.2.190.0080.00614.97
7.2.180.0060.00915.17
7.2.170.0090.00615.14
7.2.160.0070.00315.05
7.2.150.0030.01016.86
7.2.140.0110.00316.52
7.2.130.0180.00017.00
7.2.120.0100.00316.85
7.2.110.0000.01216.90
7.2.100.0140.00316.91
7.2.90.0000.01217.08
7.2.80.0060.00616.70
7.2.70.0050.00517.08
7.2.60.0070.00417.02
7.2.50.0080.00416.91
7.2.40.0060.01216.87
7.2.30.0100.00716.78
7.2.20.0100.00016.87
7.2.10.0060.00917.07
7.2.00.0060.01018.06
7.1.330.0040.01115.86
7.1.320.0090.00915.81
7.1.310.0100.00315.91
7.1.300.0100.00015.96
7.1.290.0030.01015.80
7.1.280.0030.00615.79
7.1.270.0060.00615.99
7.1.260.0060.00915.73
7.1.250.0100.00315.57
7.1.240.0070.00715.63
7.1.230.0000.01315.83
7.1.220.0060.00915.82
7.1.210.0040.01115.82
7.1.200.0040.00715.87
7.1.190.0000.00915.69
7.1.180.0080.00615.72
7.1.170.0040.00815.80
7.1.160.0030.01416.02
7.1.150.0070.00715.63
7.1.140.0100.00315.80
7.1.130.0100.00315.85
7.1.120.0000.01615.96
7.1.110.0090.00615.85
7.1.100.0050.01016.95
7.1.90.0040.00815.70
7.1.80.0040.01215.96
7.1.70.0040.00616.31
7.1.60.0110.00717.62
7.1.50.0100.00616.20
7.1.40.0050.00415.91
7.1.30.0060.00615.90
7.1.20.0060.00915.94
7.1.10.0030.00615.77
7.1.00.0020.04519.07
7.0.330.0050.00315.20
7.0.320.0030.01015.45
7.0.310.0090.00315.57
7.0.300.0040.01115.44
7.0.290.0000.01415.46
7.0.280.0070.00715.53
7.0.270.0030.01015.51
7.0.260.0040.01415.45
7.0.250.0060.00615.54
7.0.240.0000.00815.41
7.0.230.0100.00415.45
7.0.220.0040.00415.45
7.0.210.0040.00415.55
7.0.200.0090.00716.08
7.0.190.0050.00315.34
7.0.180.0030.00615.49
7.0.170.0100.00015.31
7.0.160.0030.00615.25
7.0.150.0030.00615.57
7.0.140.0060.04018.71
7.0.130.0070.00715.64
7.0.120.0000.00915.36
7.0.110.0090.00615.29
7.0.100.0080.04517.77
7.0.90.0050.02817.76
7.0.80.0030.04617.80
7.0.70.0060.03617.80
7.0.60.0100.04617.77
7.0.50.0030.04817.90
7.0.40.0090.04616.85
7.0.30.0060.04316.80
7.0.20.0050.04016.88
7.0.10.0120.01816.81
7.0.00.0030.05216.78
5.6.400.0060.00914.70
5.6.390.0090.00314.39
5.6.380.0100.00314.61
5.6.370.0110.00314.75
5.6.360.0030.01314.37
5.6.350.0030.00614.61
5.6.340.0110.00314.47
5.6.330.0060.00614.78
5.6.320.0070.00714.39
5.6.310.0170.00014.41
5.6.300.0060.00614.53
5.6.290.0090.00614.83
5.6.280.0070.03517.63
5.6.270.0000.01014.72
5.6.260.0030.00714.44
5.6.250.0100.04317.64
5.6.240.0070.04217.72
5.6.230.0070.04217.60
5.6.220.0030.02817.56
5.6.210.0090.04617.55
5.6.200.0090.04417.76
5.6.190.0120.04517.77
5.6.180.0100.04217.70
5.6.170.0080.03317.88
5.6.160.0100.04217.88
5.6.150.0050.03317.80
5.6.140.0030.03317.70
5.6.130.0050.04717.84
5.6.120.0140.02317.84
5.6.110.0080.04017.85
5.6.100.0110.04217.83
5.6.90.0070.05117.72
5.6.80.0100.03517.55
5.6.70.0100.03717.36
5.6.60.0120.04017.55
5.6.50.0070.04417.28
5.6.40.0070.04517.54
5.6.30.0190.03317.51
5.6.20.0100.03017.32
5.6.10.0050.03017.59
5.6.00.0070.02517.42
5.5.380.0050.04717.38
5.5.370.0050.04217.34
5.5.360.0050.04717.31
5.5.350.0060.02617.36
5.5.340.0070.04717.62
5.5.330.0120.03817.63
5.5.320.0070.02917.59
5.5.310.0090.04017.65
5.5.300.0070.04717.65
5.5.290.0050.03917.49
5.5.280.0080.02517.52
5.5.270.0120.03017.62
5.5.260.0130.04017.62
5.5.250.0030.05117.38
5.5.240.0070.04017.28
5.5.230.0050.02917.31
5.5.220.0100.02117.29
5.5.210.0070.04317.23
5.5.200.0060.04117.20
5.5.190.0050.04017.38
5.5.180.0080.03717.26
5.5.170.0030.00714.25
5.5.160.0090.03517.20
5.5.150.0120.03217.21
5.5.140.0070.03717.22
5.5.130.0110.04017.30
5.5.120.0070.03817.28
5.5.110.0070.04717.28
5.5.100.0070.04517.38
5.5.90.0020.04517.25
5.5.80.0050.04617.22
5.5.70.0140.03917.07
5.5.60.0050.04117.19
5.5.50.0050.04317.36
5.5.40.0070.04317.17
5.5.30.0030.03417.17
5.5.20.0100.04017.31
5.5.10.0020.04617.13
5.5.00.0080.04017.06
5.4.450.0050.04215.26
5.4.440.0070.02015.29
5.4.430.0050.02615.27
5.4.420.0080.04415.14
5.4.410.0080.04115.17
5.4.400.0100.04014.97
5.4.390.0050.04515.08
5.4.380.0090.03715.06
5.4.370.0080.03315.02
5.4.360.0020.04215.07
5.4.350.0060.04314.99
5.4.340.0070.04115.11
5.4.330.0030.00311.35
5.4.320.0110.03615.02
5.4.310.0030.04215.00
5.4.300.0080.04215.10
5.4.290.0060.04115.26
5.4.280.0050.03715.06
5.4.270.0060.03415.11
5.4.260.0050.03515.11
5.4.250.0120.03315.11
5.4.240.0140.03515.15
5.4.230.0060.04115.11
5.4.220.0080.03915.06
5.4.210.0090.03714.98
5.4.200.0050.03715.09
5.4.190.0060.04115.12
5.4.180.0060.04315.11
5.4.170.0080.03714.96
5.4.160.0020.04615.10
5.4.150.0110.03815.06
5.4.140.0060.03813.78
5.4.130.0050.02313.78
5.4.120.0070.03913.79
5.4.110.0090.03313.82
5.4.100.0040.02313.89
5.4.90.0080.03713.79
5.4.80.0020.04013.81
5.4.70.0080.03513.73
5.4.60.0030.04313.77
5.4.50.0050.04013.75
5.4.40.0080.03213.77
5.4.30.0050.03413.82
5.4.20.0020.04013.79
5.4.10.0050.03213.83
5.4.00.0060.03613.59
5.3.290.0100.03312.91
5.3.280.0100.03512.91
5.3.270.0050.03912.87
5.3.260.0090.02212.83
5.3.250.0030.04112.90
5.3.240.0090.04112.85
5.3.230.0060.04212.90
5.3.220.0030.04112.88
5.3.210.0050.04012.88
5.3.200.0070.02312.92
5.3.190.0080.03212.91
5.3.180.0120.02412.89
5.3.170.0060.03812.82
5.3.160.0070.02312.90
5.3.150.0080.03712.84
5.3.140.0100.03812.90
5.3.130.0070.04312.87
5.3.120.0050.04012.83
5.3.110.0100.03312.91
5.3.100.0050.03512.61
5.3.90.0060.03712.55
5.3.80.0090.03512.61
5.3.70.0020.03012.53
5.3.60.0130.03512.60
5.3.50.0070.03812.55
5.3.40.0100.03512.56
5.3.30.0050.03712.56
5.3.20.0070.03812.47
5.3.10.0030.03712.42
5.3.00.0030.04112.41
5.2.170.0070.06011.19
5.2.160.0070.06011.06
5.2.150.0030.06011.04
5.2.140.0030.06311.14
5.2.130.0130.05711.02
5.2.120.0070.06011.13
5.2.110.0130.05311.25
5.2.100.0030.04711.25
5.2.90.0030.02711.22
5.2.80.0030.04011.21
5.2.70.0100.03310.97
5.2.60.0030.05711.10
5.2.50.0030.03710.95
5.2.40.0070.06011.02
5.2.30.0070.05711.11
5.2.20.0070.05711.01
5.2.10.0070.06010.96
5.2.00.0000.06710.80
5.1.60.0030.06310.48
5.1.50.0030.05010.48
5.1.40.0070.05310.48
5.1.30.0070.05310.48
5.1.20.0030.05710.48
5.1.10.0030.04310.48
5.1.00.0100.05310.48
5.0.50.0000.05310.48
5.0.40.0100.03310.48
5.0.30.0000.04710.48
5.0.20.0000.04710.48
5.0.10.0000.03310.48
5.0.00.0000.07010.48
4.4.90.0000.03710.48
4.4.80.0030.02710.48
4.4.70.0000.04010.48
4.4.60.0000.02010.48
4.4.50.0070.03010.48
4.4.40.0030.04310.48
4.4.30.0030.03010.48
4.4.20.0030.03010.48
4.4.10.0000.03310.48
4.4.00.0070.04710.48
4.3.110.0070.03010.48
4.3.100.0030.03310.48
4.3.90.0030.03310.48
4.3.80.0030.05710.48
4.3.70.0000.03710.48
4.3.60.0030.03710.48
4.3.50.0000.03710.48
4.3.40.0000.05010.48
4.3.30.0000.03710.48
4.3.20.0030.02710.48
4.3.10.0100.03010.48
4.3.00.0000.02010.48

preferences:
43.88 ms | 401 KiB | 5 Q