Last active
November 14, 2020 13:30
-
-
Save matfin/08a11b774b7e3ec737bb970767d04179 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
| const hammerTime = async (url, numCalls) => { | |
| const start = performance.now(); | |
| const results = []; | |
| for(let i = 0; i < numCalls; i++) { | |
| const res = await fetch(url); | |
| const data = await res.text(); | |
| results.push(data); | |
| } | |
| const end = performance.now(); | |
| return `${numCalls} calls to ${url} took: ${end - start}ms`; | |
| }; | |
| // send through 20 calls every second | |
| setInterval(async () => { | |
| let result = await hammerTime('https://mattfinucane.com', 20); | |
| console.log(result); | |
| }, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment