Pow2 (v4)

Revision 4 of this benchmark created on


Setup

this.sqr = function(x) {
      return x * x;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
mult
var i = 0;
var len = 100;
var a = 0;
while (i < len) {
  a += i * i;
  i++;
}
ready
pow
var i = 0;
var len = 100;
var a = 0;
while (i < len) {
  a += Math.pow(i, 2);
  i++;
}
ready
sqr
var i = 0;
var len = 100;
var a = 0;
while (i < len) {
  a += this.sqr(2);
  i++;
}
ready
sqr-defined
var sqr = new Function('x', 'return x*x');

var i = 0;
var len = 100;
var a = 0;
while (i < len) {
  a += sqr(2);
  i++;
}
ready

Revisions

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