asm-simple

JavaScript performance comparison

Revision 7 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function MyASMNotAnom(stdlib, foreign, heap) {

    "use asm";
    var sqrt = stdlib.Math.sqrt;
  
    function square(x) {
      x = +x;
      return +(x * x);
    }
  
    function Diag(x, y) {
      x = +x; // x has type double
      y = +y; // y has type double
      return +sqrt(+square(x) + +square(y));
    };
  
    return {
      Diag: Diag
    };
  };
  
  var asmMod = MyASMNotAnom({
    Math: window.Math
  });
  
  
  var add_asm = (function MyAOTMod(stdlib, foreign, heap) {

    "use asm";
    var sqrt = stdlib.Math.sqrt;
  
    function square(x) {
      x = +x;
      return +(x * x);
    }
    return function(x, y) {
      x = +x; // x has type double
      y = +y; // y has type double
      return +sqrt(+square(x) + +square(y));
    };
  }(window));
  add_asm(12.12, 11.11); //trigger compilation (?)
  
  var add_reg_asmstyle = (function MyAsmLikeRegularMod() {
  
    var sqrt = Math.sqrt;
  
    function square(x) {
      x = +x;
      return +(x * x);
    }
    return function(x, y) {
      x = +x; // x has type double
      y = +y; // y has type double
      return +sqrt(+square(x) + +square(y));
    };
  }());
  
  
  
  var add_reg = (function MyStrictProfile() {

    "use strict";
    var sqrt = Math.sqrt;
  
    function square(x) {
      return (x * x)
    }
  
    return function(x, y) {
      return sqrt(square(x) + square(y));
    };
  }())
  
  var numbers = [];
  for (var i = 0; i < 10000; i += 1) {
    numbers.push(Math.random());
  }

};
</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
asm
var num1, num2;
for (var i = 0, l = numbers.length * 100; i < l; i += 1) {
  num1 = numbers[l % i];
  num2 = numbers[l % (i + 1)];
  add_asm(num1, num2);
}
pending…
normal (strict mode)
var num1, num2;
for (var i = 0, l = numbers.length * 100; i < l; i += 1) {
  num1 = numbers[l % i];
  num2 = numbers[l % (i + 1)];
  add_reg(num1, num2);
}
pending…
asm-style (no profile)
var num1, num2;
for (var i = 0, l = numbers.length * 100; i < l; i += 1) {
  num1 = numbers[l % i];
  num2 = numbers[l % (i + 1)];
  add_reg_asmstyle(num1, num2);
}
pending…
asm-no-anon-func
var num1, num2;
for (var i = 0, l = numbers.length * 100; i < l; i += 1) {
  num1 = numbers[l % i];
  num2 = numbers[l % (i + 1)];
  asmMod.Diag(num1, num2);
}
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