fib nomal vs asm.js (v7)

Revision 7 of this benchmark created on


Setup

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;
  })();

Test runner

Ready to run.

Testing in
TestOps/sec
fib 1 nomal
fibNomal(25);
ready
fib 2 like asm
fibLikeAsm(25);
ready
fib 3 use asm
fibUseAsm(25);
ready

Revisions

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