Objects As Hashes (100k) (v4)

Revision 4 of this benchmark created on


Description

I found that creation of keys up to 10 million members was linear, no noticeable performance hit in Chrome. I decided that a better test however would be comparison of CRUD operations on a filled "Hash" of 1 million.

Setup

//I would really only like to run fill hash once ever
    var hash = hash || {},
        n = 100000,
        random = Math.floor((Math.random() * n) + 1),
        variableName = "name" + random,
        otherName = "other" + random;
    
    function fill(n) {
      var i = 0;
      for (i; i < n; i++) {
        hash["name" + i] = i;
      }
    }
    
    if (typeof hash.name100 === "undefined") {
       fill(n);
    }

Teardown


    random = Math.floor((Math.random() * n) + 1);
    variableName = "name" + random;
    otherName = "other" + random;
  

Test runner

Ready to run.

Testing in
TestOps/sec
Create
hash[otherName] = 5;
var v = 5;
Math.floor(v);
ready
Read
var b = hash[variableName];
var v = 5;
Math.floor(b);
ready
Update
hash[variableName] = 1;
var v = 5;
Math.floor(v);
 
ready
Destroy
delete hash[variableName];
var v = 5;
Math.floor(v);
ready
Control
var v = 5;
Math.floor(v);
ready

Revisions

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