SqRt vs Newton

JavaScript performance comparison

Revision 3 of this test case created by ConstableBrew

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var raw_val = Math.random() * 100;
    var ret_val;
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Newton
ret_val = raw_val / 2;
ret_val = (ret_val + raw_val / ret_val) / 2;
ret_val = (ret_val + raw_val / ret_val) / 2;
ret_val = (ret_val + raw_val / ret_val) / 2;
ret_val = (ret_val + raw_val / ret_val) / 2;
pending…
Math.sqrt
ret_val = Math.sqrt(raw_val);
pending…
Int Newton
ret_val = raw_val >> 1;
ret_val = (ret_val + raw_val / ret_val) >> 1;
ret_val = (ret_val + raw_val / ret_val) >> 1;
ret_val = (ret_val + raw_val / ret_val) >> 1;
ret_val = (ret_val + raw_val / ret_val) >> 1;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment