localStorage vs. Objects (v23)

Revision 23 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 lg = localStorage.getItem.bind(localStorage);

  var FOO = {
    foo: "body { background: blue; margin: 10px; padding: 10px; color: black; text-decoration: none; }"
  };

  var value;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Reading from an object
value = FOO.foo;
ready
Reading from localStorage
value = localStorage.getItem("foo");
ready
Local storage w/o function
value = localStorage.foo;
ready
Object with function
function fn() {
  return FOO.foo;
}

value = fn();
ready
Bound LocalStorge
value = lg("foo")
ready

Revisions

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