blob: e2a0eb13126ed5824ab2794b323df741eedd09ea (
plain)
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 duration = process.env.duration || 0;
const url = process.env.test_url;
const start = process.hrtime();
let throughput = 0;
function request(res) {
res.on('data', () => {});
res.on('error', () => {});
res.on('end', () => {
throughput++;
const diff = process.hrtime(start);
if (duration > 0 && diff[0] < duration) {
run();
} else {
console.log(JSON.stringify({ throughput }));
}
});
}
function run() {
http.get(url, request);
}
run();
|