sqrt perf

JavaScript performance comparison

Test case created

Preparation code

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) > 5e-15);
      return guess;  // return the approximate square root

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
sqrt fn

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers


Comment form temporarily disabled.

Add a comment