localStorage Operations

JavaScript performance comparison

Test case created by Paddy O'Reilly

Info

Test the speed of various way to save and retrieve to and from localStorage

Preparation code

<script>localStorage.setItem("name", "")</script>
<script>
Benchmark.prototype.setup = function() {
    var value = String(Math.random());
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
set: localStorage.setItem("name", value)
localStorage.setItem("name", value);
pending…
set: localStorage[name]
localStorage["name"] = value;
pending…
set: localStorage.name = value
localStorage.name = value;
pending…
get: localStorage.getItem("name")
var value = localStorage.getItem("name")
pending…
get: localStorage[name]
var value = localStorage['name'];
pending…
get: localStorage.name
var value = localStorage.name;
pending…

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

Compare results of other browsers

0 comments

Add a comment