forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_is_http_token.js
52 lines (48 loc) · 1002 Bytes
/
check_is_http_token.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict';
const common = require('../common.js');
const _checkIsHttpToken = require('_http_common')._checkIsHttpToken;
const bench = common.createBenchmark(main, {
key: [
'TCN',
'ETag',
'date',
'Vary',
'server',
'Server',
'status',
'version',
'Expires',
'alt-svc',
'location',
'Connection',
'Keep-Alive',
'content-type',
'Content-Type',
'Cache-Control',
'Last-Modified',
'Accept-Ranges',
'content-length',
'x-frame-options',
'x-xss-protection',
'Content-Encoding',
'Content-Location',
'Transfer-Encoding',
'alternate-protocol',
':', // invalid input
'@@',
'中文呢', // unicode
'((((())))', // invalid
':alternate-protocol', // fast bailout
'alternate-protocol:' // slow bailout
],
n: [1e6],
});
function main(conf) {
const n = +conf.n;
const key = conf.key;
bench.start();
for (var i = 0; i < n; i++) {
_checkIsHttpToken(key);
}
bench.end(n);
}