-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbench.js
44 lines (40 loc) · 1009 Bytes
/
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
var request = require('request');
var apiBenchmark = require('api-benchmark');
var fs = require('fs');
var service = {
server1: 'http://localhost:1337/api/v1/'
};
let options = {
method: 'POST',
uri: service.server1 + "auth/token",
body: {
username: process.env.USERNAME,
password: process.env.PASSWORD
},
json: true
};
request.post(options, (err, res, body) => {
if (err) {
return console.log(err);
}
let token = body.token;
if (!token) {
return console.error("no token");
}
var routes = {
route1: 'bands?token=' + token
};
apiBenchmark.measure(service, routes, {
debug: false,
runMode: 'parallel',
maxConcurrentRequests: 10,
delay: 0,
maxTime: 100000,
minSamples: 100,
stopOnError: false
}, (err, results) => {
apiBenchmark.getHtml(results, (error, html) => {
fs.writeFileSync('benchmarks.html', html);
});
});
});