LoginSignup
13
13

More than 5 years have passed since last update.

WebStorageのパフォーマンス比較

Last updated at Posted at 2014-02-21

WebStorageのパフォーマンスについて気になったので、jsperfで試してみました。

jsperfでの結果

  • MemoryStorageとしているのは、ただ変数に入れてるだけのバージョンです。
  • Storage使う時はJSON.parse、JSON.stringifyしたりすると思うのでそんな感じで比較してます

MemoryStorage

    var memoryStorage = {
      _data: {},
      setItem: function(key, data) {
        this._data[key] = data;
      },
      getItem: function(key) {
        return this._data[key];
      }
    };

SPAでのSessionStorage

  • 基本的にはどれもそんなに変わらない感じでしたが、ChromeだとMemoryStorageが高速でした。
  • SinglePageApplicationの場合はページ読み込みは最初しか発生しないので、ガベージされない変数に突っ込むのもSessionStorage使うのも違いがないと思うのでこれなら自分でSessionStorage的なものを作って使う方がいいのかなと思ったりしました。
13
13
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13