localStorage-string-size

JavaScript performance comparison

Test case created by Nicholas C. Zakas

Preparation code

<script>
var small = "XXXXXXXXX-XXXXXXXXX-XXXXXXXXX-XXXXXXXXX-XXXXXXXXX-XXXXXXXXX-XXXXXXXXX-XXXXXXXXX-XXXXXXXXX-XXXXXXXXX-";
var medium = small + small + small + small + small;
var large = medium + medium;
var xlarge = large + large;

localStorage.setItem("a", small);
localStorage.setItem("b", medium);
localStorage.setItem("c", large);
localStorage.setItem("d", xlarge);
</script>
      
<script>
Benchmark.prototype.teardown = function() {
  localStorage.clear();

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Read small value (100 chars)
var value = localStorage.getItem("a");
pending…
Read medium value (500 chars)
var value = localStorage.getItem("b");
pending…
Read large value (1000 chars)
var value = localStorage.getItem("c");
pending…
Read xlarge value (2000 chars)
var value = localStorage.getItem("d");
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.

0 Comments