sinus/cosinus performance improvements

JavaScript performance comparison

Test case created by rezoner

Info

http://devmaster.net/forums/topic/4648-fast-and-accurate-sinecosine/

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    B = 4 / Math.PI;
    C = -4/(Math.PI * Math.PI);
   
    function sine(a) {
      return B * a + C * a * Math.abs(a);
    }
};
</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
Math.sin
var foo = Math.sin(1.78);
pending…
sine
var foo = sine(1.78);
pending…
inline
var foo = B * 1.78 + C * 1.78 * Math.abs(1.78);
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