localStorage vs. Cookies (v48)

Revision 48 of this benchmark created on


Description

Tests the difference between operations with localStorage as compared to cookies.

Preparation HTML

<script>
  var value = document.cookie;
  var testData = new Array(1000).join('abc');
  if (value.length) {
      localStorage.setItem("foo", document.cookie);
  } else {
      value = testData;
      localStorage.setItem("foo", value);
      document.cookie = value;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Reading from cookie
value = document.cookie;
ready
Reading from localStorage getItem
value = localStorage.getItem('foo');
ready
Writing to cookie
document.cookie = "bar=" + testData;
ready
Writing to localStorage property
localStorage.setItem("bar", testData);
ready

Revisions

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