Fast Cos vs Math Cos

JavaScript performance comparison

Test case created by Kirill Dmitrenko

Preparation code

<script>
function fastCos(x) {
    var x2 = x * x;
    var x4 = x2 * x2;
    var x6 = x4 * x2;
    var x8 = x6 * x2;
    var x10 = x8 * x2;
    return 1 - (1814400 * x2 - 151200 * x4 + 5040 * x6 - 90 * x8 + x10) / 3628800;
}
</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.cos
Math.cos(Math.random());
pending…
Fast cos
fastCos(Math.random());
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