0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/http/set_header.js
Denys Otrishko f7a1ef6fb5 benchmark: clean up config resolution in multiple benchmarks
This removes 'to Number' casting in multiple benchmarks (which is
handled by the benchmark runner) and cleans up some var usage in changed
benchmarks.

PR-URL: https://github.com/nodejs/node/pull/31581
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-02-02 19:45:02 -08:00

28 lines
491 B
JavaScript

'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({ n, value }) {
const og = new OutgoingMessage();
bench.start();
for (let i = 0; i < n; i++) {
og.setHeader(value, '');
}
bench.end(n);
}