3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Condition { public function __constructor($at, $next = null) { $this->at = $at; $this->next = $next; } public function eval() { $result = $this->actualEval(); if ($result !== false && $this->next) $result = $this->next->eval(); return $result; } public function actualEval() { return false; } public function getCause() { return $this->cause ?: ($this->prev ? $this->prev->getCause() : null); } } class Condition1 extends Condition { public function __constructor($at, $next = null) { parent::__constructor($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->condition1; } } class X { protected function check(\Closure $callback) { $condition = new Condition1( $this, new Condition2($this) ); if (!$condition->eval()) { $this->log($condition->getCause()); $this->cleanup(); } else $callback(); } public function doSomething() { $this->check(function () use ($this) { $this->reallyDoSomething(); }); } public function reallyDoSomething() { echo "1"; } public function cleanup() { echo "> cleanup.\n"; } public function log($str) { echo "> $str\n"; } } $x = new X(); $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)
7.0.20.0430.04720.16
7.0.10.0130.07020.20
7.0.00.0170.05320.26
5.6.170.0300.04020.50
5.6.160.0100.07020.49
5.6.150.0070.03718.27
5.6.140.0070.08018.25
5.6.130.0070.06018.18
5.6.120.0100.08321.12
5.6.110.0070.07720.89
5.6.100.0200.08021.09
5.6.90.0070.07720.97
5.6.80.0030.03720.51
5.5.310.0200.08020.34
5.5.300.0170.06018.03
5.5.290.0130.07718.02
5.5.280.0070.07320.80
5.5.270.0030.04720.97
5.5.260.0070.08020.80
5.5.250.0030.08720.46
5.5.240.0130.08020.16

preferences:
143.18 ms | 1394 KiB | 7 Q