Speed of sessionStorage [closed]

守給你的承諾、 提交于 2019-12-23 21:30:59

问题


I am making a website where the user can select options on an item such as size or colour. However, I am using Backbone and when the model is updated the view is re-rendered and options are reset to default.

To stop this, I have used sessionStorage to load the values back in after it is refreshed. This works as well as I would want but I am worried about performance when there is a large amount of items and data to be read. Would there be a visible delay between values being loaded or is sessionStorage fast enough for this not be a problem?


回答1:


This jsperf test should reassure you https://jsperf.com/localstorage-vs-objects/47

As you can see, looking up in the sessionStorage (or the localStorage for that matter) is a lot slower that looking up in an object.

But, that said, you can do more than 2,000,000 (on my firefox on my computer) of those operations per second. So don't worry about this your users are never going to feel that latency :)



来源:https://stackoverflow.com/questions/45148967/speed-of-sessionstorage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!