I was doing some timing of a function on the weekend and in one of the
loops, I had to multiply a variable by 2 - easy enough - $i*2

but then I remembered that in C, it's quicker to do a left shift - so $i<<1

but this actually took longer to execute in php than the $i*2 - can anyone
confirm my test? I iterated ~28,000 times. Each time, there was 2 places
where I was doing the left shift. The time (including all the other stuff I
was doing in the function) for $i*2 was ~12secs, and $i<<1 was ~19secs.

I am running PHP4.0.6 (download cgi version from php.net) on a win98 system
(500MHz Celeron if that changes anything)

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to