Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Memory vs Local vs Session
(version: 0)
Comparing performance of:
Local vs Session vs Control
Created:
3 years ago
by:
Guest
Jump to the latest result
Tests:
Local
localStorage.setItem('foo', 'bar')
Session
sessionStorage.setItem('foo', 'bar')
Control
var foo = 'bar'
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Local
Session
Control
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Browser/OS:
Chrome 144 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Local
114941.7 Ops/sec
Session
112215.6 Ops/sec
Control
42693352.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks. **What is being tested?** The provided benchmark compares three different approaches to storing data in memory: `localStorage`, `sessionStorage`, and native variable storage (`var`). **Options compared:** * **LocalStorage**: Stores data in a user's browser session, tied to their browsing context. The data persists even after the page has closed. * **SessionStorage**: Similar to LocalStorage, but with some key differences (more on that later). It also stores data in the user's browser session and persists even after the page has closed. * **Native Variable Storage (`var`)**: Stores data in native JavaScript variables, which are stored in memory. This type of storage is not persisted across sessions. **Pros and Cons of each approach:** * **LocalStorage**: + Pros: - Data is persisted across sessions - Easier to access from multiple pages or domains + Cons: - Can be slower due to security restrictions (e.g., limited access to native APIs) - More prone to storage leaks (accidentally storing large amounts of data) * **SessionStorage**: + Pros: - Faster than LocalStorage, as it has fewer security restrictions - Still persists across sessions, but is cleared when the session ends + Cons: - Limited access to native APIs due to security restrictions - May not be compatible with older browsers * **Native Variable Storage (`var`)**: + Pros: - Fastest and most reliable option - No security restrictions, making it ideal for certain use cases + Cons: - Data is lost when the session ends (or the browser closes) - Can be more challenging to manage data across multiple pages or domains **Library:** * **none**: This benchmark does not rely on any external libraries. **Special JavaScript feature or syntax:** * None are mentioned in this specific benchmark. However, if you're interested in learning about other features and their implications for performance, feel free to ask! **Other alternatives:** If you're looking for alternative storage mechanisms, consider the following: * **IndexedDB**: A more advanced, client-side database that allows for structured data storage. * **Web Storage APIs (IndexedDB-like)**: More modern and efficient than traditional LocalStorage and SessionStorage. * **Native Storage Mechanisms**: Depending on your use case, you might need to resort to native mechanisms like file system storage or cache-based storage. Keep in mind that the choice of storage mechanism depends on your specific requirements, performance needs, and compatibility constraints.
Related benchmarks:
localStorage vs sessionStorage vs Reading a Hardcoded Array Speedtest
Just localStorage vs sessionStorage Speedtest
In-memory, localStorage and sessionStorage Speedtest
window.localStorage vs localStorage
Comments
Confirm delete:
Do you really want to delete benchmark?