localStorage vs. Objects (v41)

Revision 41 of this benchmark created on


Description

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

Preparation HTML

<script>
  var data = JSON.stringify([{"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

Ready to run.

Testing in
TestOps/sec
Reading from an object
value = JSON.parse(FOO.foo);
ready
Reading from localStorage
value = JSON.parse(localStorage.foo);
ready

Revisions

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