All pastes #276263 Raw Edit

Mine

public php v1 · immutable
·published 2006-12-12 03:46 UTC
rendered paste body
<?phpsleep(1);function microtime_float(){   list($usec, $sec) = explode(" ", microtime());   return ((float)$usec + (float)$sec);}// PARTOOPfunction Abc_constructor2(& $x){	$x['a'] = 5;	$x['b'] = 10;	$x['c'] = 15;}function Abc_add2(& $x, $amount){	$x['a'] += $amount;	$x['b'] += $amount;	$x['c'] += $amount;		}function Abc_multiplyA2(& $x, $amount){	$x['a'] *= $amount;}function Abc_multiplyB2(& $x, $amount){	$x['b'] *= $amount;}function Abc_multiplyC2(& $x, $amount){	$x['c'] *= $amount;}// DEOOPfunction Abc_constructor(& $a,& $b,& $c){	$a = 5;	$b = 10;	$c = 15;}function Abc_add(& $a,& $b,& $c, $amount){	$a += $amount;	$b += $amount;	$c += $amount;		}function Abc_multiplyA(& $a, $amount){	$a *= $amount;}function Abc_multiplyB(& $b, $amount){	$b *= $amount;}function Abc_multiplyC(& $c, $amount){	$c *= $amount;}// OOPclass Abc {	public $a;	public $b;	public $c;	public $d;					function __construct() 	{		$this->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.'<br>';	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.'<br>';	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'].'<br>';	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.'<br>';	break;}echo microtime_float(true) - $t;?>