forked from DenisCarriere/mbtiles-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench.js
49 lines (41 loc) · 1.26 KB
/
bench.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const path = require('path')
const axios = require('axios')
const server = require('./')
const cache = path.join(__dirname, 'test', 'fixtures')
const config = { responseType: 'arraybuffer' }
const ee = server({ cache })
// http://localhost:5000/world_zoom_0-2/2/2/2
function randomURL () {
const x = Math.round(Math.random() * 2)
const y = Math.round(Math.random() * 2)
const z = 2
return `http://localhost:5000/world_zoom_0-2/${[z, x, y].join('/')}`
}
/**
* Benchmark Results
*
* 1 request: 33.460ms
* 10 requests: 45.223ms
* 100 requests: 374.217ms
* 1K requests: 2698.584ms
* 10K requests: 25457.490ms
*/
async function bench () {
console.time('1 request')
await axios(randomURL(), config)
console.timeEnd('1 request')
console.time('10 requests')
for (let i = 0; i < 10; i++) await axios(randomURL(), config)
console.timeEnd('10 requests')
console.time('100 requests')
for (let i = 0; i < 100; i++) await axios(randomURL(), config)
console.timeEnd('100 requests')
console.time('1K requests')
for (let i = 0; i < 1000; i++) await axios(randomURL(), config)
console.timeEnd('1K requests')
console.time('10K requests')
for (let i = 0; i < 10000; i++) await axios(randomURL(), config)
console.timeEnd('10K requests')
ee.close()
}
bench()