summaryrefslogtreecommitdiff
path: root/benchmark/http/set_header.js
blob: 470d4b008187bcc7f410a262a0ae1d9b0e413166 (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
'use strict';

const common = require('../common.js');
const { OutgoingMessage } = require('_http_outgoing');

const bench = common.createBenchmark(main, {
  value: [
    'X-Powered-By',
    'Vary',
    'Set-Cookie',
    'Content-Type',
    'Content-Length',
    'Connection',
    'Transfer-Encoding',
  ],
  n: [1e6],
});

function main(conf) {
  const n = +conf.n;
  const value = conf.value;

  const og = new OutgoingMessage();

  bench.start();
  for (let i = 0; i < n; i++) {
    og.setHeader(value, '');
  }
  bench.end(n);
}