object-key-size-get

JavaScript performance comparison

Test case created by Dennis Torres

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var array1 = [];
  var array2 = [];
  
  for (var i = 0; i < 10000; i++) {
    array1.push(['a' + i, 'a' + i + 1, 'a' + i + 10, 'a' + i + 100]);
  }
  
  for (var i = 0; i < 10000; i++) {
    array2.push({ service: 'a' + i, username: 'a' + i + 1, url: 'a' + i + 10, userId: 'a' + i + 100 });
  }

};

Benchmark.prototype.teardown = function() {
  array1 = null;
  array2 = 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
Short
array1.forEach(function (item) {
  console.log(item[0]);
  console.log(item[1]);
  console.log(item[2]);
  console.log(item[3]);
});
pending…
Long
array2.forEach(function (item) {
  console.log(item.service);
  console.log(item.username);
  console.log(item.url);
  console.log(item.userId);
});
pending…

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

0 Comments