note 14923 deleted from language.operators.assignment by jimw

From: Date: Mon, 29 Oct 2001 00:51:06 +0000
Subject: note 14923 deleted from language.operators.assignment by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-19538@lists.php.net to get a copy of this message
$u -= $v is noticeably faster than $u = $u - $v. We have tested it three times for each situation with the following code snippet: - - - - - - - - - - - - - - - - - - function gcd($u, $v) { do { if ($u < $v) { $t = $v; $v = $u; $u = $t; } $u -= $v; // $u = $u - $v; } while ($u > 0); return $v; } list($msec, $sec) = split(" ", microtime()); $time1 = $sec + $msec; for ($i=0; $i<10000; $i++) { gcd($u, $v); } list($msec, $sec) = split(" ", microtime()); $time2 = $sec + $msec; echo $time2 - $time1; - - - - - - - - - - - - - - - - - - Execution time is about 15.5 secs on a Celeron 333 for $u -= $v, and 16.7 secs for $u = $u - $v.

« previous php.notes (#19538) next »