variables vs. Cookies (v45)

Revision 45 of this benchmark created on


Description

Tests the difference between operations with cookies and reading from memory

Preparation HTML

<script>
  var value = document.cookie;
  var value2 = "ok";


  if (value.length) {
      localStorage.setItem("foo", document.cookie);
  } else {
      value = "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef";
      localStorage.setItem("foo", value);
      document.cookie = value;
  }
  
  var value;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Reading from cookie
value = document.cookie;
ready
Reading from a variable
value = value2;
ready
Writing to cookie
document.cookie = "bar=fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo";
ready
Writing to a variable
value2 = value;
ready

Revisions

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