benchmark: shorten config name in http benchmark
Shorten the config name in check_invalid_header_char so it would not result in long lines that make the benchmark result hard to read. PR-URL: https://github.com/nodejs/node/pull/18452 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
ef2861961c
commit
d3841ec872
@ -3,6 +3,10 @@
|
|||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const _checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar;
|
const _checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar;
|
||||||
|
|
||||||
|
// Put it here so the benchmark result lines will not be super long.
|
||||||
|
const LONG_AND_INVALID = 'Here is a value that is really a folded header ' +
|
||||||
|
'value\r\n this should be supported, but it is not currently';
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
key: [
|
key: [
|
||||||
// Valid
|
// Valid
|
||||||
@ -21,8 +25,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'en-US',
|
'en-US',
|
||||||
|
|
||||||
// Invalid
|
// Invalid
|
||||||
'Here is a value that is really a folded header value\r\n this should be \
|
'LONG_AND_INVALID',
|
||||||
supported, but it is not currently',
|
|
||||||
'中文呢', // unicode
|
'中文呢', // unicode
|
||||||
'foo\nbar',
|
'foo\nbar',
|
||||||
'\x7F'
|
'\x7F'
|
||||||
@ -31,6 +34,9 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n, key }) {
|
function main({ n, key }) {
|
||||||
|
if (key === 'LONG_AND_INVALID') {
|
||||||
|
key = LONG_AND_INVALID;
|
||||||
|
}
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
_checkInvalidHeaderChar(key);
|
_checkInvalidHeaderChar(key);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user