simple array access

JavaScript performance comparison

Revision 2 of this test case created by Eric Burley

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var a = [],
    b = [],
    c = [],
    a_len = 1000,
    b_len = 5000,
    c_len = 100000,
    i, a_randex, b_randex, c_randex;
  
  for (i = 0; i < a_len; i++) {
    a[a.length] = 10;
  }
  for (i = 0; i < b_len; i++) {
    b[b.length] = 10;
  }
  for (i = 0; i < c_len; i++) {
    c[c.length] = 10;
  }
  
  a_randex = parseInt(Math.random() * a_len, 10);
  b_randex = parseInt(Math.random() * b_len, 10);
  c_randex = parseInt(Math.random() * c_len, 10);

};

Benchmark.prototype.teardown = function() {
  a = b = c = null;

};
</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
randomly access an element of a 1000 member array
var ra = a[a_randex];
pending…
randomly access an element of a 5000 member array
var rb = b[b_randex];
pending…
randomly access an element of a 100000 member array
var rc = c[c_randex];
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