localStorage overhead

JavaScript performance comparison

Test case created by Tom Doan

Info

This test case shows the amount of overhead, if any, incurred when accessing data from localStorage directly compared to assigning the localStorage data to a variable and accessing the variable, as well as getting the value from a pre-populated select element.

Preparation code

<select id="test">
  <option>A</option>
  <option selected="selected">B</option>
  <option>C</option>
</select>
<input id="output" />
<script>
  localStorage['answer'] = 'B';
  var oSel = document.getElementById('test'),
      oOut = document.getElementById('output'),
      sAns = localStorage['answer'];
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
localStorage
oOut.value = localStorage['answer'];
pending…
variable
oOut.value = sAns;
pending…
select
oOut.value = oSel[oSel.selectedIndex].text;
pending…

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

Compare results of other browsers

0 comments

Add a comment