localStorage String Size Retrieval
JavaScript performance comparison
Info
Test to determine if it's faster to read 10 small values from localStorage or one big value.
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;
</script>
<script>
Benchmark.prototype.setup = function() {
localStorage.setItem("a", small);
localStorage.setItem("b", small);
localStorage.setItem("c", small);
localStorage.setItem("d", small);
localStorage.setItem("e", small);
localStorage.setItem("f", small);
localStorage.setItem("g", small);
localStorage.setItem("h", small);
localStorage.setItem("i", small);
localStorage.setItem("j", small);
localStorage.setItem("z", large);
};
Benchmark.prototype.teardown = function() {
localStorage.clear();
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Reading 10 small values |
|
pending… |
Reading one large value |
|
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. Here’s a list of current revisions for this page:
- Revision 1: published by Nicholas C. Zakas
- Revision 2: published
0 comments