3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Model { public function get() {} } class Foo { protected $model; public function __construct() { $this->model = new Model; } public function doSomethingGetModelOnce() { $model = $this->getModel(); for ($i = 0; $i < 1000; $i++) { $model->get(); } } public function doSomethingGetModelNTimes() { for ($i = 0; $i < 500; $i++) { $this->getModel()->get(); } } protected function getModel() { return $this->model; } } $foo = new Foo(); $time0 = microtime(true); $foo->doSomethingGetModelOnce(); $time1 = microtime(true); $foo->doSomethingGetModelNTimes(); $time2 = microtime(true); var_dump(1000*($time1-$time0), 1000*($time2-$time1));

preferences:
30.43 ms | 402 KiB | 5 Q