dynamic or fixed

JavaScript performance comparison

Test case created by quimcalpe and last updated

Info

Testing dynamic arrays vs fixed length arrays, inspiration from Alex Gaynor's talk: https://speakerdeck.com/alex/why-python-ruby-and-javascript-are-slow

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
dynamic length
function square(n) {
  var ret = [];
  for (var i=0; i<n; i++) {
    ret[i] = i*i;
  }
  return ret;
}

square(100);
pending…
fixed lenght
function square(n) {
  var ret = new Array(n);
  for (var i=0; i<n; i++) {
    ret[i] = i*i;
  }
  return ret;
}

square(100);
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