fib nomal vs asm.js

JavaScript performance comparison

Revision 8 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function fibNomal(x) {
    if (x < 3) return 1;
    return fibNomal(x - 2) + fibNomal(x - 1);
  }
  
  function fibLikeAsm(x) {
    x = x | 0;
    if ((x | 0) < 3) return 1;
    return ((fibLikeAsm((x - 2) | 0) | 0) + (fibLikeAsm((x - 1) | 0) | 0)) | 0;
  }
  
  var fibUseAsm = (function () {

    'use asm';
    function fib(x) {
      x = x | 0;
      if ((x | 0) < 3) return 1;
      return ((fib((x - 2) | 0) | 0) + (fib((x - 1) | 0) | 0)) | 0;
    }
    return fib;
  })();
  
  
  

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
fib 1 nomal heavy
fibNomal(30);
pending…
fib 2 like asm heavy
fibLikeAsm(30);
pending…
fib 3 use asm heavy
fibUseAsm(30);
pending…
fib 4 nomal light
for(var i = 0; i < 200000; ++i) fibNomal(5);
pending…
fib 5 like asm light
for(var i = 0; i < 200000; ++i) fibLikeAsm(5);
pending…
fib 6 use asm light
for(var i = 0; i < 200000; ++i) fibUseAsm(5);
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.

0 Comments