2 ms·
That's because most localStorage implementations are in-memory. Chrome and FF (as far as I know) have to synchronously load all your localStorage data from disk
by kevingadd 13y ago
That's because most localStorage implementations are in-memory. Chrome and FF (as far as I know) have to synchronously load all your localStorage data from disk at page load and then flush changes to disk later. This increases your page load times dramatically if the user has a spinning rust hard drive. (This is part of why localStorage has a ~2.5mb cap in Chrome and a ~5mb cap in Firefox.)
So, in practice you're benchmarking actual I/O vs in-memory data structure updates.