Skip to content

Commit 3512921

Browse files
authored
benchmark: update to use internal module for header character checks
1 parent b067022 commit 3512921

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

benchmark/http/check_invalid_header_char.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
// TODO: benchmark has access to internal modules?
5-
const _checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar;
64

75
const groupedInputs = {
86
// Representative set of inputs from an AcmeAir benchmark run:
@@ -52,9 +50,13 @@ const inputs = [
5250
const bench = common.createBenchmark(main, {
5351
input: inputs.concat(Object.keys(groupedInputs)),
5452
n: [1e6],
53+
}, {
54+
flags: ['--expose-internals', '--no-warnings'],
5555
});
5656

5757
function main({ n, input }) {
58+
const checkInvalidHeaderChar = require('internal/http/common')._checkInvalidHeaderChar;
59+
5860
let inputs = [input];
5961
if (Object.hasOwn(groupedInputs, input)) {
6062
inputs = groupedInputs[input];
@@ -63,7 +65,7 @@ function main({ n, input }) {
6365
const len = inputs.length;
6466
bench.start();
6567
for (let i = 0; i < n; i++) {
66-
_checkInvalidHeaderChar(inputs[i % len]);
68+
checkInvalidHeaderChar(inputs[i % len]);
6769
}
6870
bench.end(n);
6971
}

benchmark/http/check_is_http_token.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
// TODO: benchmark has access to internal modules?
5-
const _checkIsHttpToken = require('_http_common')._checkIsHttpToken;
64

75
const bench = common.createBenchmark(main, {
86
key: [
@@ -39,12 +37,16 @@ const bench = common.createBenchmark(main, {
3937
'alternate-protocol:', // slow bailout
4038
],
4139
n: [1e6],
40+
}, {
41+
flags: ['--expose-internals', '--no-warnings'],
4242
});
4343

4444
function main({ n, key }) {
45+
const checkIsHttpToken = require('internal/http/common')._checkIsHttpToken;
46+
4547
bench.start();
4648
for (let i = 0; i < n; i++) {
47-
_checkIsHttpToken(key);
49+
checkIsHttpToken(key);
4850
}
4951
bench.end(n);
5052
}

0 commit comments

Comments
 (0)