Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
localStorage and sessionStorage Speedtest2
(version: 0)
Comparing performance of:
Control vs localStorage vs sessionStorage
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
localStorage.setItem('foo', 'bar') sessionStorage.setItem('foo', 'bar')
Tests:
Control
var FOO = 'bar';var FOO = 'bar';var FOO = 'bar';var FOO = 'bar';var FOO = 'bar';
localStorage
var FOO = localStorage.getItem('foo');var FOO = localStorage.getItem('foo');var FOO = localStorage.getItem('foo');var FOO = localStorage.getItem('foo');var FOO = localStorage.getItem('foo');
sessionStorage
var FOO = sessionStorage.getItem('foo');var FOO = sessionStorage.getItem('foo');var FOO = sessionStorage.getItem('foo');var FOO = sessionStorage.getItem('foo');var FOO = sessionStorage.getItem('foo');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Control
localStorage
sessionStorage
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and explain what is being tested. **What is being tested?** The test cases are measuring the execution speed of assigning values to variables `FOO` using different storage mechanisms: local storage (`localStorage`) and session storage (`sessionStorage`). The variables are assigned multiple times, with identical values `'bar'`. **Options compared** There are three options compared: 1. **Control**: This option represents a baseline measurement without using any storage mechanism. 2. **localStorage**: This option uses `localStorage` to store the value `'bar'`. 3. **sessionStorage**: This option uses `sessionStorage` to store the value `'bar'`. **Pros and Cons of each approach** 1. **Control**: The pros are that it doesn't involve any external storage, which can simplify the code and reduce overhead. However, the cons are that it may not accurately represent real-world scenarios where storage is required. 2. **localStorage**: The pros are that `localStorage` provides a standardized way to store data locally in the browser, making it easy to share data between pages or applications. The cons are that: * Storage space can be limited, which might impact performance if too much data is stored. * Data is not immediately available when the page loads; it needs to be fetched from storage. * `localStorage` has a single origin policy, which means only data stored in a specific domain can be accessed by other pages on that domain. This can lead to security issues if data is not properly sanitized or validated. 3. **sessionStorage**: The pros are similar to `localStorage`, but with the added benefit of: * Data is automatically cleared when the page is closed, which helps prevent memory leaks and reduces storage space requirements. * Has a stronger single origin policy, making it more secure than `localStorage`. * Provides better support for asynchronous operations. **Library and its purpose** In this benchmark, there are no explicit libraries mentioned. However, it's essential to note that `localStorage` and `sessionStorage` are standardized browser APIs, not third-party libraries. **Special JS feature or syntax** There is no special JavaScript feature or syntax being tested in this benchmark. The code uses basic variable assignment and string literals. **Other alternatives** If you were to create a similar benchmark, you might consider adding additional test cases for: * **indexDB**: A more powerful storage system than `localStorage` and `sessionStorage`, but also more complex to use. * **IndexedDB transactions**: If you want to simulate concurrent access to stored data or perform atomic operations. * **Web Storage alternatives**: Like Google's Chrome-specific storage mechanisms, such as [chrome.storage](https://developer.chrome.com/extensions/storage). Keep in mind that these alternatives might not be relevant for this specific benchmark, and the focus should remain on comparing the basic performance characteristics of `localStorage` and `sessionStorage`.
Related benchmarks:
localStorage and sessionStorage Speedtest
localStorage vs sessionStorage vs Reading a Hardcoded Array Speedtest
Just localStorage vs sessionStorage Speedtest
In-memory, localStorage and sessionStorage Speedtest
Comments
Confirm delete:
Do you really want to delete benchmark?