Objects As Hashes (1 mil)

Benchmark created by Parris 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 = 1000000,
        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;
ready
Read
var b = hash[variableName];
ready
Update
hash[variableName] = 1;
ready
Destroy
delete hash[variableName];
ready

Revisions

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