Indexed localStorageDB

JavaScript performance comparison

Revision 14 of this test case created

Info

Index performance test for https://github.com/vshjxyz/Indexed-localStorageDB to compare the speed with/without indexes

Preparation code

<script src="https://rawgithub.com/vshjxyz/Indexed-localStorageDB/master/localstoragedb.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var lib = new localStorageDB("library");
    var index_lib = new localStorageDB("library_indexed");
    if (lib.isNew()) {
   
      lib.createTable("books", ["id", "title", "author", "year", "copies"]);
   
      for (var i = 0; i < 150; i++) {
        lib.insert("books", {
          id: "B00" + i,
          title: "Phantoms in the brain " + i,
          author: "Ramachandran",
          year: (1999 + i),
          copies: (10 + i)
        });
      }
   
      lib.commit();
    }
   
    if (index_lib.isNew()) {
   
      index_lib.createTable("books", ["id", "title", "author", "year", "copies"], ["id", "year"]);
   
      for (var i = 0; i < 150; i++) {
        index_lib.insert("books", {
          id: "B00" + i,
          title: "Phantoms in the brain " + i,
          author: "Ramachandran",
          year: (1999 + i),
          copies: (10 + i)
        });
      }
   
      index_lib.commit();
    }
};

Benchmark.prototype.teardown = function() {
    lib.drop();
    lib.commit();
   
    index_lib.drop();
    index_lib.commit();
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Select speed without indexes (best case)
if (lib.query("books", {
  id: "B00149"
}).length > 0) {
  return;
}
pending…
Select speed with indexes (best case)
if (index_lib.query("books", {
  id: "B00149"
}).length > 0) {
  return;
}
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