Speed of sessionStorage [closed]
Asked Answered
E

1

4

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?

Extractive answered 17/7, 2017 at 16:12 Comment(2)
Worry about a performance problem when you have a performance problem.Vacua
Generate a given size of random data then test the execution time. Incrementally increase the size of the data until the delay increases to the point of being unacceptable. That is completely dependent upon the browser, system capabilities, and allocated resources. The only answer to this question is "Test it".Goode
S
8

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 :)

Svelte answered 17/7, 2017 at 16:17 Comment(3)
That is far faster than I was expecting it to be. Thanks for showing me!Extractive
Do not hesitate to approve my answer if it suits you. If not, are you expecting anything else?Svelte
Sorry I forgot about that. It's now the accepted answer, thanks.Extractive

© 2022 - 2024 — McMap. All rights reserved.