sqrt perf
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
function sqrt(num) {
// Create an initial guess by simply dividing by 3.
var lastGuess, guess = num / 3;
// Loop until a good enough approximation is found.
do {
lastGuess = guess; // store the previous guess
// find a new guess by averaging the old one with
// the original number divided by the old guess.
guess = (num / guess + guess) / 2;
// Loop again if the product isn't close enough to
// the original number.
} while(Math.abs(lastGuess  guess) > 5e15);
return guess; // return the approximate square root
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test  Ops/sec  

native 

pending… 
sqrt fn 

pending… 
You can edit these tests or add even more tests to this page by appending /edit
to the URL.
0 comments
Comment form temporarily disabled.