a = 5; $this->b = 10; $this->c = 15; } function add($amount) { $this->a += $amount; $this->b += $amount; $this->c += $amount; } function multiplyA($amount) { $this->a *= $amount; } function multiplyB($amount) { $this->b *= $amount; } function multiplyC($amount) { $this->c *= $amount; } } // --- $iterations = 300000; $test = "inlined"; // <-- CHANGE THE STRING HERE $t = microtime_float(true); switch ($test) { case "inlined": for ($i=$iterations; $i--;) { $x_a = NULL; $x_b = NULL; $x_c = NULL; $x_d = NULL; $x_a = 5; $x_b = 10; $x_c = 15; $x_a += 1; $x_b += 1; $x_c += 1; $x_a *= 3; $x_b *= 3; $x_c *= 3; $x_d = $x_a + $x_b + $x_c; } echo $x_d.'
'; break; case "deoop": for ($i=$iterations; $i--;) { $x_a = NULL; $x_b = NULL; $x_c = NULL; $x_d = NULL; Abc_constructor($x_a,$x_b,$x_c); Abc_add($x_a,$x_b,$x_c,1); Abc_multiplyA($x_a,3); Abc_multiplyB($x_b,3); Abc_multiplyC($x_c,3); $x_d = $x_a + $x_b + $x_c; } echo $x_d.'
'; break; case "partoop": for ($i=$iterations; $i--;) { $x = array('a'=>NULL,'b' => NULL, 'c'=> NULL, 'd'=> NULL); Abc_constructor2($x); Abc_add2($x,1); Abc_multiplyA2($x,3); Abc_multiplyB2($x,3); Abc_multiplyC2($x,3); $x['d'] = $x['a'] + $x['b'] + $x['c']; } echo $x['d'].'
'; break; case "oop": for ($i=$iterations; $i--;) { $x = new Abc(); $x->add(1); $x->multiplyA(3); $x->multiplyB(3); $x->multiplyC(3); $x->d = $x->a + $x->b + $x->c; } echo $x->d.'
'; break; } echo microtime_float(true) - $t; ?>