Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Storage Perf
(version: 0)
Comparing performance of:
Session Storage vs Local Storage vs Cookie Storage
Created:
4 years ago
by:
Guest
Jump to the latest result
Tests:
Session Storage
sessionStorage.getItem('fdsfs');
Local Storage
localStorage.getItem('fdsfs');
Cookie Storage
const getCookie = (docCookie, sKey) => decodeURIComponent(docCookie.replace(new RegExp(`(?:(?:^|.*;)\\s*${encodeURIComponent(sKey).replace(/[-.+*]/g, '\\$&')}\\s*\\=\\s*([^;]*).*$)|^.*$`), '$1')) || null; getCookie(document.cookie, 'fdsfs');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Session Storage
Local Storage
Cookie Storage
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/126.0.6478.153 Mobile/15E148 Safari/604.1
Browser/OS:
Chrome Mobile iOS 126 on iOS 17.5
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Session Storage
5908235.5 Ops/sec
Local Storage
5570916.5 Ops/sec
Cookie Storage
1133125.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview of the Benchmark** The provided benchmark measures the performance of different storage mechanisms in JavaScript: `sessionStorage`, `localStorage`, and cookie-based storage. **Options Compared** The benchmark compares three options: 1. **`sessionStorage`**: a client-side, browser-based storage mechanism that stores data locally on the user's device. 2. **`localStorage`**: a client-side, browser-based storage mechanism that stores data locally on the user's device, with a larger capacity than `sessionStorage`. 3. **Cookie-based storage**: a server-side storage mechanism that uses cookies to store and retrieve data. **Pros and Cons of Each Approach** 1. **`sessionStorage`**: * Pros: fast, lightweight, and easy to implement. * Cons: data is lost when the user closes their browser or clears browsing history. 2. **`localStorage`**: * Pros: larger capacity than `sessionStorage`, can store more complex data structures. * Cons: slower than `sessionStorage`, and may have security risks if not implemented properly. 3. **Cookie-based storage**: * Pros: can store large amounts of data, secure (if implemented correctly). * Cons: slower than other options due to the need for a server-side setup, and may require additional security measures. **Library Usage** None of the benchmark definitions use any libraries beyond standard JavaScript functions. However, it's worth noting that in real-world applications, you might use libraries like `sessionstorage` or `localStorage` APIs to interact with these storage mechanisms. **Special JS Features or Syntax** The benchmark does not use any special JavaScript features or syntax. It simply measures the performance of accessing and retrieving data from each storage mechanism using standard JavaScript methods (e.g., `getItem`, `setItem`). **Alternatives** Other alternatives for storing data in web applications include: 1. **IndexedDB**: a client-side storage mechanism that provides more advanced data structures and querying capabilities than `localStorage`. 2. **Web Storage API Extensions**: such as Web Cryptography API, which allows encryption of stored data. 3. **Server-side storage mechanisms**: like server-side cookies or token-based authentication, which may offer additional security benefits. Overall, the benchmark provides a simple yet informative way to compare the performance of different storage mechanisms in JavaScript, helping developers understand the trade-offs between these options when building web applications.
Related benchmarks:
Dataview vs Custom - Read double
Lru cache non-async version with 99 percent hit ratio
Lru cache non-async version: time complexity of cache-miss
Queue data structure
Map vs Object: Lookup, insert and delete
Comments
Confirm delete:
Do you really want to delete benchmark?