localstorage vs amplify.store vs storage.js (v3)

Revision 3 of this benchmark created by John Papa on


Description

Checking the speed of Store.JS vs Amplify.Store

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="https://raw.github.com/douglascrockford/JSON-js/master/json2.js">
</script>
<script src="https://raw.github.com/appendto/amplify/master/store/amplify.store.js">
</script>
<script src="https://raw.github.com/marcuswestin/store.js/master/store.js">
</script>

Teardown


    store.clear();
    amplify.store("a1", null);
    amplify.store("a2", null);
    amplify.store("a3", null);
    localStorage.removeItem('l1');
    localStorage.removeItem('l2');
    localStorage.removeItem('l3');
  

Test runner

Ready to run.

Testing in
TestOps/sec
Store.JS
$(function() {
  store.set("s1", 1);
  store.set("s2", {
    person: {
      name: 'John',
      age: 40
    }
  });
  store.set("s3", [{
    person: {
      name: 'John',
      age: 40
    }
  }, {
    person: {
      name: 'Sam',
      age: 34
    }
  }]);
  var svar1 = store.get("s1");
  var svar2 = store.get("s2");
  var svar3 = store.get("s3");
});
ready
Amplify.Store
$(function() {
  amplify.store("a1", 1);
  amplify.store("a2", {
    person: {
      name: 'John',
      age: 40
    }
  });
  amplify.store("a3", [{
    person: {
      name: 'John',
      age: 40
    }
  }, {
    person: {
      name: 'Sam',
      age: 34
    }
  }]);
  var avar1 = amplify.store("a1");
  var avar2 = amplify.store("a2");
  var avar3 = amplify.store("a3");
});
ready
Vanilla LocalStorage
$(function() {
  localStorage.setItem('l1', 1);
  localStorage.setItem("l2", {
    person: {
      name: 'John',
      age: 40
    }
  });
  localStorage.setItem("l3", [{
    person: {
      name: 'John',
      age: 40
    }
  }, {
    person: {
      name: 'Sam',
      age: 34
    }
  }]);
  var lvar1 = localStorage.getItem('l1');
  var lvar2 = localStorage.getItem('l2');
  var lvar3 = localStorage.getItem('l3');
});
ready

Revisions

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