'Localstorage' reading

JavaScript performance comparison

Revision 5 of this test case created

Info

Test for benchmarking localstorage reading

Preparation code

<script>
  localStorage.setItem("foo", "body { background: blue; margin: 10px; padding: 10px; color: black; text-decoration: none; }");

  var largeValue = "Foo";
  for (var i = 0; i < 1668; i++) // 1668*6 bytes = 10kb
  {
    largeValue += "Bar";
  }
  var largeLargeValue = largeValue + largeValue; // 20kb
  var largeX3Value = largeLargeValue + largeLargeValue; // 40kb
  var largeX6Value = largeX3Value + largeX3Value + largeX3Value + largeX3Value; // 160kb
  localStorage.setItem("largeFoo", largeValue);
  localStorage.setItem("largeLargeFoo", largeLargeValue);
  localStorage.setItem("largeX3Foo", largeX3Value);
  localStorage.setItem("largeX6Foo", largeX6Value);

  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
Read from getItem()
value = localStorage.getItem('foo');
pending…
Reading a large value with getItem()
value = localStorage.getItem('largeFoo');
pending…
Reading large value 2
value = localStorage.getItem('largeLargeFoo');
pending…
Reading large value 3
value = localStorage.getItem('largeX3Foo');
pending…
Reading large value 4
value = localStorage.getItem('largeX6Foo');
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