localStorage vs globals (v13)

Revision 13 of this benchmark created by PW on


Description

Just a test to check performance of global storage vs global variables

Preparation HTML

<script>
  var CURRENT_NODE = 'DEV';
  localStorage.setItem('currentNode', 'DEV');
</script>
<script>
  function currentNode() {
    return localStorage.getItem('currentNode');
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
using localStorage - accessor
var count = 0;
for (var i = 0; i < 1000; i++) {
  if (localStorage.currentNode == 'DEV') {
    count++;
  }
}
ready
using localStorage - getItem
var count = 0;
for (var i = 0; i < 1000; i++) {
  if (localStorage.getItem('currentNode') == 'DEV') {
    count++;
  }
}
ready

Revisions

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