3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Condition { private $value; private $variable = false; public function setCondition($new_value) { switch ($new_value) { case 'cond2': $this->variable = true; break; case 'cond4': $this->variable = false; break; } $this->value = $new_value; } public function getCondition() { return $this->value; } public function isVariableSet() { return ($this->variable === true); } } $conditions = array( 'cond1', 'cond2', 'cond3', 'cond4','cond5' ); $cond = new Condition(); $results = array(); $setCondGetVariable = function($condition) use($cond) { $cond->setCondition($condition); if ($cond->isVariableSet() == true) { $toggle = 'on'; } else { $toggle = 'off'; } return $toggle.' ; '; } $results = array_map($setCondGetVariable, $conditions); var_dump($results);

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)
5.4.290.0050.05612.52
5.4.280.0060.05112.41
5.4.270.0080.07512.41
5.4.260.0110.05212.42
5.4.250.0060.05212.42
5.4.240.0100.04812.41
5.4.230.0100.05312.41
5.4.220.0070.05412.41
5.4.210.0080.05112.41
5.4.200.0140.05312.41
5.4.190.0060.05512.41
5.4.180.0120.07712.40
5.4.170.0150.06112.41
5.4.160.0210.08212.41
5.4.150.0120.04012.40
5.4.140.0080.05312.09
5.4.130.0070.05512.07
5.4.120.0150.10912.04
5.4.110.0120.06312.04
5.4.100.0080.05612.04
5.4.90.0090.06112.04
5.4.80.0090.05912.04
5.4.70.0120.06912.03
5.4.60.0150.06112.03
5.4.50.0120.06412.04
5.4.40.0110.06512.02
5.4.30.0090.04112.02
5.4.20.0030.05712.02
5.4.10.0120.06112.02
5.4.00.0170.07711.51
5.3.280.0080.07112.71
5.3.270.0090.04612.73
5.3.260.0190.05712.72
5.3.250.0200.08212.72
5.3.240.0200.07712.72
5.3.230.0070.08512.71
5.3.220.0230.08012.68
5.3.210.0100.08312.68
5.3.200.0090.05712.68
5.3.190.0120.06512.67
5.3.180.0140.07912.67
5.3.170.0100.04612.67
5.3.160.0070.04512.67
5.3.150.0110.04712.68
5.3.140.0110.03812.66
5.3.130.0120.03812.66
5.3.120.0130.03912.66
5.3.110.0110.04812.66
5.3.100.0140.06912.13
5.3.90.0070.04412.11
5.3.80.0090.05412.10
5.3.70.0120.05412.10
5.3.60.0120.05012.09
5.3.50.0100.04812.04
5.3.40.0180.07112.04
5.3.30.0190.12111.99
5.3.20.0130.05811.78
5.3.10.0150.04811.74
5.3.00.0050.04211.73

preferences:
143.02 ms | 1398 KiB | 7 Q