localStorage vs. Objects

JavaScript performance comparison

Revision 40 of this test case created

Info

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

Preparation code

<script>
  data = [{"id":1,"title":"Default","siteList":"","url_protocol":false,"url_subdomain":false,"url_domain":true,"url_path":false,"strUseText":"","hashAlgorithm":"md5","username":"","modifier":"","passwordLength":"8","selectedCharset":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./","passwordPrefix":"","passwordSuffix":"","whereToUseL33t":"off","l33tLevel":"0"},{"id":2,"title":"Alphanumeric","siteList":"","url_protocol":false,"url_subdomain":false,"url_domain":true,"url_path":false,"strUseText":"","hashAlgorithm":"md5","username":"","modifier":"","passwordLength":8,"selectedCharset":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789","passwordPrefix":"","passwordSuffix":"","whereToUseL33t":"off","l33tLevel":0}];

  localStorage.setItem("foo", data);
 
  var FOO = {
   foo: data
  };
 
  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
Reading from an object
value = FOO.foo;
pending…
Reading from localStorage
value = localStorage.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