I think the title is pretty much descriptive. I'm working on a idle game project using Ember.js and for now I'm saving to the localstorage 25 times per second instead of saving every 10 or 20 seconds. It's a really small amount of data and I'm not experiencing any performance issue (at least in my machine), but I'd like to know if this is bad and if so, how bad it is. Thanks :)
There are two things :
1 ) Each browser supports different intervals of getting
or setting
localstorage
values
If you performs too many times within a period the browser may hang and become unresponsive!
For best performance you should save to a local variable then periodically save it to localstorage
.
Here are the list of browser's and their time taken to first read or write:
On Internet Explorer 9, all reads take 0ms. I’m not sure how Internet Explorer is loading this data, but it doesn't appear to be the same as with other browsers.
On Opera, first read takes ~1ms and subsequent reads take 0ms.
2 ) It also depends on the size of values that you are getting/setting.
Remember :
-localstorage
has a limited capacity per domain and browser.
- And avoid to use localstorage
while your page loads.
As my opinion : Give maximum time to localstorage
if you don't want to crssh your game while user's are playing.
And calculate that maximum amount of data is used while user play the game and set time to write localstorage
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With