-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrunTests.ts
32 lines (27 loc) · 847 Bytes
/
runTests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { renderToChart } from './renderToChart'
const urls = [
'https://neon-cf.capaj.workers.dev/',
'https://planetscale-cf.capaj.workers.dev/',
'https://turso-cf.capaj.workers.dev/'
]
let allTimes = [] as number[][]
async function test() {
// fetch every url 150 times in 3 second intervals
for (let i = 0; i < 150; i++) {
const timings = await Promise.all(
urls.map(async (url, i) => {
const res = await fetch(url + 'users')
const json = await res.json()
return json.timingMs
})
)
allTimes.push(timings)
console.log('timings:', timings)
await new Promise((resolve) => setTimeout(resolve, 3000))
}
}
await test()
console.log(`✅ done, recorded ${allTimes.length} timings`)
await renderToChart(allTimes, 'select.png')
console.log('Chart generated as chart.png')
export {}