1'use strict'; 2 3const common = require('../common.js'); 4const _checkIsHttpToken = require('_http_common')._checkIsHttpToken; 5 6const bench = common.createBenchmark(main, { 7 key: [ 8 'TCN', 9 'ETag', 10 'date', 11 'Vary', 12 'server', 13 'Server', 14 'status', 15 'version', 16 'Expires', 17 'alt-svc', 18 'location', 19 'Connection', 20 'Keep-Alive', 21 'content-type', 22 'Content-Type', 23 'Cache-Control', 24 'Last-Modified', 25 'Accept-Ranges', 26 'content-length', 27 'x-frame-options', 28 'x-xss-protection', 29 'Content-Encoding', 30 'Content-Location', 31 'Transfer-Encoding', 32 'alternate-protocol', 33 ':', // invalid input 34 '@@', 35 '中文呢', // unicode 36 '((((())))', // invalid 37 ':alternate-protocol', // fast bailout 38 'alternate-protocol:', // slow bailout 39 ], 40 n: [1e6], 41}); 42 43function main({ n, key }) { 44 bench.start(); 45 for (let i = 0; i < n; i++) { 46 _checkIsHttpToken(key); 47 } 48 bench.end(n); 49} 50