localStorage-string-size
JavaScript performance comparison
Info
A benchmark to see if the size of strings stored in localStorage affects its read performance.
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.
| Test | Ops/sec | |
|---|---|---|
Read small value (100 chars) |
|
pending… |
Read medium value (500 chars) |
|
pending… |
Read large value (1000 chars) |
|
pending… |
Read xlarge value (2000 chars) |
|
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
- Revision 3: published
0 comments