localStorage vs. Objects

JavaScript performance comparison

Revision 25 of this test case created by women

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; }"
  };

  var value;
</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
本地存储中用方法取
value = localStorage.getItem("foo");
pending…
从本地存取中对象取
value = localStorage["foo"];
pending…
本地存取用点取
value = localStorage.foo;
pending…
Object with function
 
pending…
Bound LocalStorge
 
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