• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common.js');
3const PORT = common.PORT;
4
5const bench = common.createBenchmark(main, {
6  res: ['normal', 'setHeader', 'setHeaderWH'],
7  duration: 5
8});
9
10const type = 'bytes';
11const len = 4;
12const chunks = 0;
13const chunkedEnc = 0;
14const c = 50;
15
16// normal: writeHead(status, {...})
17// setHeader: statusCode = status, setHeader(...) x2
18// setHeaderWH: setHeader(...), writeHead(status, ...)
19function main({ res, duration }) {
20  process.env.PORT = PORT;
21  const server = require('../fixtures/simple-http-server.js')
22  .listen(PORT)
23  .on('listening', () => {
24    const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
25
26    bench.http({
27      path: path,
28      connections: c,
29      duration
30    }, () => {
31      server.close();
32    });
33  });
34}
35