3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Condition { var $causedNext = false; var $cause = null; public function __construct($at, $next = null) { $this->at = $at; $this->next = $next; } public function evalCondition() { $this->causedNext = false; $result = $this->actualEval(); if ($result !== false && $this->next) { $result = $this->next->evalCondition(); if ($result === false) $this->causedNext = true; } return $result; } public function actualEval() { return false; } public function getCause() { return $this->causedNext ? $this->next->getCause() : $this->cause; } } class Condition1 extends Condition { public function __construct($at, $next = null) { parent::__construct($at, $next); $this->cause = "cause 1"; } public function actualEval() { return $this->at->condition1; } } class Condition2 extends Condition { public function __constructor($at, $next = null) { parent::__constructor($at, $next); $this->cause = "cause 2"; } public function actualEval() { return $this->at->condition2; } } class X { var $condition1 = false; var $condition2 = false; public function __construct($c1, $c2) { $this->condition1 = $c1; $this->condition2 = $c2; } protected function check(\Closure $callback) { $condition = new Condition1( $this, new Condition2($this) ); if (!$condition->evalCondition()) { $this->log($condition->getCause()); } else return $callback(); $this->cleanup(); return null; } public function doSomething() { $this->check(function () { return $this->reallyDoSomething(); }); } public function reallyDoSomething() { echo "Done!"; } public function cleanup() { echo "> cleanup.\n"; } public function log($str) { echo "> $str\n"; } } echo "f, f\n"; $x = new X(false, false); $x->doSomething(); echo "f, t\n"; $x = new X(false, true); $x->doSomething(); echo "t, f\n"; $x = new X(true, false); $x->doSomething(); echo "t, t\n"; $x = new X(true, true); $x->doSomething();

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.55
8.3.50.0110.01021.27
8.3.40.0180.00418.83
8.3.30.0070.00718.79
8.3.20.0130.00320.16
8.3.10.0050.00321.98
8.3.00.0050.00323.66
8.2.180.0070.00716.38
8.2.170.0140.00322.96
8.2.160.0070.00720.37
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0000.00920.82
8.2.120.0000.00826.35
8.2.110.0070.00320.94
8.2.100.0080.00317.93
8.2.90.0000.00919.21
8.2.80.0080.00017.97
8.2.70.0080.00017.63
8.2.60.0050.00318.05
8.2.50.0040.00418.09
8.2.40.0000.00922.15
8.2.30.0040.00419.36
8.2.20.0040.00417.60
8.2.10.0000.00718.01
8.2.00.0080.00018.00
8.1.280.0090.00625.92
8.1.270.0080.00022.14
8.1.260.0000.01028.09
8.1.250.0060.00328.09
8.1.240.0080.00322.52
8.1.230.0040.00817.76
8.1.220.0030.00517.74
8.1.210.0080.00018.77
8.1.200.0000.00917.25
8.1.190.0030.00617.35
8.1.180.0040.00418.10
8.1.170.0080.00018.64
8.1.160.0000.00720.79
8.1.150.0030.00520.78
8.1.140.0040.00419.57
8.1.130.0030.00317.78
8.1.120.0000.00717.49
8.1.110.0040.00417.39
8.1.100.0000.00817.44
8.1.90.0070.00017.50
8.1.80.0040.00417.48
8.1.70.0040.00417.46
8.1.60.0090.00017.62
8.1.50.0030.00617.48
8.1.40.0120.00017.54
8.1.30.0030.00517.56
8.1.20.0050.00317.55
8.1.10.0070.00017.58
8.1.00.0000.00817.59
8.0.300.0070.00018.77
8.0.290.0000.00716.88
8.0.280.0000.00718.47
8.0.270.0000.00717.35
8.0.260.0070.00017.30
8.0.250.0030.00716.98
8.0.240.0040.00417.08
8.0.230.0050.00217.00
8.0.220.0040.00416.97
8.0.210.0040.00416.89
8.0.200.0070.00017.02
8.0.190.0070.00516.94
8.0.180.0040.00417.04
8.0.170.0080.00017.09
8.0.160.0050.00216.95
8.0.150.0030.00316.98
8.0.140.0060.00316.93
8.0.130.0000.00513.44
8.0.120.0000.00816.97
8.0.110.0040.00416.96
8.0.100.0050.00316.85
8.0.90.0020.00516.98
8.0.80.0060.00917.00
8.0.70.0040.00417.04
8.0.60.0040.00416.95
8.0.50.0000.00817.06
8.0.30.0130.00516.98
8.0.20.0090.00917.40
8.0.10.0000.00817.01
8.0.00.0110.00716.83
7.4.330.0000.00516.83
7.4.320.0000.00716.56
7.4.300.0030.00316.55
7.4.290.0030.00316.46
7.4.280.0060.00316.64
7.4.270.0000.00816.52
7.4.260.0030.00316.48
7.4.250.0000.00716.46
7.4.240.0030.00616.69
7.4.230.0050.00216.64
7.4.220.0120.01616.74
7.4.210.0080.00816.45
7.4.200.0040.00416.45
7.4.160.0120.00316.56
7.4.150.0100.00917.40
7.4.140.0130.00817.86
7.4.130.0140.00616.44
7.4.120.0120.00916.54
7.4.110.0060.01016.55
7.4.100.0070.01116.73
7.4.90.0030.01416.34
7.4.80.0060.01219.39
7.4.70.0120.00616.52
7.4.60.0070.01016.60
7.4.50.0070.01116.29
7.4.40.0160.00316.47
7.4.30.0030.01816.64
7.4.00.0110.00414.85
7.3.330.0000.00613.44
7.3.320.0030.00313.40
7.3.310.0000.00716.48
7.3.300.0040.00416.42
7.3.290.0070.00016.37
7.3.280.0080.01116.40
7.3.270.0070.01017.40
7.3.260.0180.00016.66
7.3.250.0120.00616.42
7.3.240.0100.00716.37
7.3.230.0100.00716.45
7.3.210.0040.01216.59
7.3.200.0060.01519.39
7.3.190.0100.01016.58
7.3.180.0100.00616.55
7.3.170.0100.00616.59
7.3.160.0100.00616.62
7.2.330.0100.00816.75
7.2.320.0070.01016.80
7.2.310.0070.01416.78
7.2.300.0060.01216.48
7.2.290.0000.01816.79
7.2.60.0000.01416.99
7.2.00.0190.00019.55
7.1.200.0060.00615.73
7.1.100.0060.00917.71
7.1.70.0080.00417.02
7.1.60.0160.00919.40
7.1.50.0150.00316.98
7.1.00.0070.07322.48
7.0.200.0040.00416.75
7.0.60.0170.08321.73
7.0.50.0000.06317.92
7.0.40.0130.04720.35
7.0.30.0300.08020.24
7.0.20.0330.07720.19
7.0.10.0030.04320.30
7.0.00.0070.07320.23
5.6.280.0030.03320.92
5.6.210.0030.07320.53
5.6.200.0030.06018.16
5.6.190.0070.04020.68
5.6.180.0170.04320.64
5.6.170.0300.07320.55
5.6.160.0170.07320.62
5.6.150.0100.03318.23
5.6.140.0030.08718.25
5.6.130.0030.05318.25
5.6.120.0030.04721.05
5.6.110.0130.06321.05
5.6.100.0100.07720.92
5.6.90.0070.05721.06
5.6.80.0030.04020.31
5.5.350.0170.08720.35
5.5.340.0100.06718.00
5.5.330.0030.05720.13
5.5.320.0670.05320.42
5.5.310.0230.07020.28
5.5.300.0070.07317.95
5.5.290.0100.07317.98
5.5.280.0070.08320.80
5.5.270.0100.03720.88
5.5.260.0070.08020.74
5.5.250.0100.03720.61
5.5.240.0200.07320.19

preferences:
51.44 ms | 401 KiB | 5 Q