tweb-i2p/src/test_cache_and_local_storage_speed.js

18 lines
562 B
JavaScript
Raw Normal View History

2021-08-03 01:44:13 +00:00
console.time('open');
caches.open('sessions').then(cache => {
console.timeEnd('open');
cache.put('/state', new Response(JSON.stringify(appStateManager.state), {headers: {'Content-Type': 'application/json'}}));
});
console.time('match');
caches.open('sessions').then(async(cache) => {
const response = await cache.match('/state');
const promise = response.json();
promise.then((json) => {
console.timeEnd('match');
});
});
console.time('getItem');
var value = JSON.parse(localStorage.getItem('state'));
console.timeEnd('getItem');