-
-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathtrack-run.js
More file actions
29 lines (21 loc) · 574 Bytes
/
track-run.js
File metadata and controls
29 lines (21 loc) · 574 Bytes
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
'use strict'
const http = require('http')
const autocannon = require('../autocannon')
const server = http.createServer(handle)
server.listen(0, startBench)
function handle (req, res) {
res.end('hello world')
}
function startBench () {
const instance = autocannon({
url: 'http://localhost:' + server.address().port
}, finishedBench)
autocannon.track(instance)
// this is used to kill the instance on CTRL-C
process.once('SIGINT', () => {
instance.stop()
})
function finishedBench (err, res) {
console.log('finished bench', err, res)
}
}