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
|
'use strict';
const common = require('../common.js');
const http = require('http');
const bench = common.createBenchmark(main, {
// unicode confuses ab on os x.
c: [50, 500],
headerDuplicates: [0, 5, 20]
});
function main({ c, headerDuplicates }) {
const server = http.createServer((req, res) => {
res.end();
});
server.listen(common.PORT, () => {
const headers = {
'Content-Type': 'text/plain',
'Accept': 'text/plain',
'User-Agent': 'nodejs-benchmark',
'Date': new Date().toString(),
'Cache-Control': 'no-cache'
};
for (let i = 0; i < headerDuplicates; i++) {
headers[`foo${i}`] = `some header value ${i}`;
}
bench.http({
path: '/',
connections: c,
headers
}, () => {
server.close();
});
});
}
|