localStorage vs. Objects

JavaScript performance comparison

Revision 34 of this test case created by

Preparation code

<script>
  var O = {};
  var cache = {
    storage: {},
    get: function (key) { return this.storage[key]; },
    set: function (key, value) { this.storage[key] = value; },
    clear: function () { this.storage = {}; }
  };
  localStorage.foo = "body { background: blue; margin: 10px; padding: 10px; color: black; text-decoration: none; }";
  O.foo = "body { background: blue; margin: 10px; padding: 10px; color: black; text-decoration: none; }";
  cache.set('foo', "body { background: blue; margin: 10px; padding: 10px; color: black; text-decoration: none; }");
  var value;
</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
value = O.foo;
pending…
value = O['foo'];
pending…
value = localStorage.foo;
pending…
value = localStorage['foo'];
pending…
value = localStorage.getItem('foo');
pending…
value = cache.get('foo');
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.

0 Comments