Welcome to mirror list, hosted at ThFree Co, Russian Federation.

set-header.js « http « benchmark - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 47681ebd1b14054a710300a52061bf9c109d53ae (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
30
31
32
33
'use strict';
const common = require('../common.js');

const bench = common.createBenchmark(main, {
  res: ['normal', 'setHeader', 'setHeaderWH'],
  duration: 5
});

const type = 'bytes';
const len = 4;
const chunks = 0;
const chunkedEnc = 0;
const c = 50;

// normal: writeHead(status, {...})
// setHeader: statusCode = status, setHeader(...) x2
// setHeaderWH: setHeader(...), writeHead(status, ...)
function main({ res, duration }) {
  const server = require('../fixtures/simple-http-server.js')
  .listen(0)
  .on('listening', () => {
    const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;

    bench.http({
      path: path,
      connections: c,
      duration,
      port: server.address().port,
    }, () => {
      server.close();
    });
  });
}