summaryrefslogtreecommitdiff
path: root/deps/node/benchmark/http/check_is_http_token.js
blob: eab075249e6f8018d3e8e13b9f4974bf23aeb152 (plain)
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
'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({ n, key }) {
  bench.start();
  for (var i = 0; i < n; i++) {
    _checkIsHttpToken(key);
  }
  bench.end(n);
}