Recently I wrote about binary search and then I said that in some languages, like PHP, bitwise division by two is not faster than the typical “/” operator. However I decided to make some experiments and here are the results.
Important Note
It’s very important to say that the following results are dependant from the machine and the environment!
Source Code
Here’s the PHP source code.
function divide($n = 1) { $a = microtime(true); for ($i = 0; $i < $n; $i++) { 300/2; } echo microtime(true) - $a; } divide(100); //divide(1000); //divide(10000); //divide(100000); //divide(1000000); //divide(10000000); |