Created
February 3, 2017 22:43
-
-
Save ConradIrwin/a634359060cbbde0e90a30e5744aa1a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function fill(cache) { | |
let list = []; | |
for (let i = 0; i < 30000; ++i) { | |
list.push(cache.put('https://example.com/probably-crash-' + i, new Response('ok'))) | |
} | |
return Promise.all(list); | |
} | |
function read(cache) { | |
let start = performance.now(); | |
cache.keys().then(keys => { | |
let end = performance.now(); | |
console.log(end - start); | |
}).catch(e => { | |
alert(e) | |
}) | |
} | |
function run () { | |
caches.open("test").then(cache => { | |
fill(cache).then(() => { | |
read(cache); | |
}) | |
}) | |
} | |
</script> | |
<div> | |
Filling <span id="filled">...</span> | |
<button onclick="run()">Crash!</button> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment