3v4l.org

run code in 300+ PHP versions simultaneously
<?php class one { private $var; public function __construct() { $this->var = array(); } public function saveIteration($a) { $this->var[] = $a; return $this->var; } public function getVar() { return $this->var; } } $one = new one(); $time_start = microtime(true); for ($i = 0; $i < 10000; $i++) { $res = $one->saveIteration($i); } echo "First took " . number_format(microtime(true) - $time_start, 3) . " sec.\n"; //reset unset($one);$one = new one(); $time_start = microtime(true); for ($i = 0; $i < 10000; $i++) { $one->saveIteration($i); } $res = $one->getVar(); echo "Second took " . number_format(microtime(true) - $time_start, 3) . " sec.";

preferences:
29.22 ms | 404 KiB | 5 Q