localStorage vs. Objects

JavaScript performance comparison

Revision 2 of this test case created

Info

Tests the difference between reading from localStorage as compared to reading data from an object.

Preparation code

<script>
  localStorage.setItem("foo", "body { background: blue; margin: 10px; padding: 10px; color: black; text-decoration: none; }");
 
  var FOO = {
   foo: "body { background: blue; margin: 10px; padding: 10px; color: black; text-decoration: none; }",
   getItem: function(name) {
    return this[name];
   }
  };
</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
Reading from an object (prop access)
var value = FOO.foo;
pending…
Reading from localStorage
var value = localStorage.getItem("foo");
pending…
Reading from an object (getter method)
var value = FOO.getItem("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. Here’s a list of current revisions for this page:

0 comments

Add a comment