localStorage vs. Objects (v2)

Revision 2 of this benchmark created on


Description

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

Preparation HTML

<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

Ready to run.

Testing in
TestOps/sec
Reading from an object (prop access)
var value = FOO.foo;
ready
Reading from localStorage
var value = localStorage.getItem("foo");
ready
Reading from an object (getter method)
var value = FOO.getItem("foo");
ready

Revisions

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