mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 23:16:30 +01:00
aba6bc34a1
Long ago, V8 was much faster switching on string lengths than values. That is no longer the case, so we can simplify a couple of methods. PR-URL: https://github.com/nodejs/node/pull/18351 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Kyle Farnung <kfarnung@microsoft.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me>
31 lines
532 B
JavaScript
31 lines
532 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(conf) {
|
|
const n = +conf.n;
|
|
const value = conf.value;
|
|
|
|
const og = new OutgoingMessage();
|
|
|
|
bench.start();
|
|
for (var i = 0; i < n; i++) {
|
|
og.setHeader(value, '');
|
|
}
|
|
bench.end(n);
|
|
}
|