diff options
author | Brian White <mscdex@mscdex.net> | 2016-05-07 17:03:35 -0400 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2016-06-14 15:13:00 -0400 |
commit | 83432bfff1e21797e497aacf4c473db1345f6334 (patch) | |
tree | 03a32d4899f3c41d7e51e40341bc7107165c696d /benchmark/http | |
parent | 918159e0f6601a6314cc7aa0eb30a170a349ff8c (diff) | |
download | android-node-v8-83432bfff1e21797e497aacf4c473db1345f6334.tar.gz android-node-v8-83432bfff1e21797e497aacf4c473db1345f6334.tar.bz2 android-node-v8-83432bfff1e21797e497aacf4c473db1345f6334.zip |
http: optimize checkInvalidHeaderChar()
This commit optimizes checkInvalidHeaderChar() by unrolling the
character checking loop a bit.
Additionally, some changes to the benchmark runner are needed in
order for the included benchmark to be run correctly. Specifically,
the regexp used to parse `key=value` parameters contained a greedy
quantifier that was causing the `key` to match part of the `value`
if `value` contained an equals sign.
PR-URL: https://github.com/nodejs/node/pull/6570
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Diffstat (limited to 'benchmark/http')
-rw-r--r-- | benchmark/http/check_invalid_header_char.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/benchmark/http/check_invalid_header_char.js b/benchmark/http/check_invalid_header_char.js new file mode 100644 index 0000000000..bef44e6316 --- /dev/null +++ b/benchmark/http/check_invalid_header_char.js @@ -0,0 +1,42 @@ +'use strict'; + +const common = require('../common.js'); +const _checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar; + +const bench = common.createBenchmark(main, { + key: [ + // Valid + '', + '1', + '\t\t\t\t\t\t\t\t\t\tFoo bar baz', + 'keep-alive', + 'close', + 'gzip', + '20091', + 'private', + 'text/html; charset=utf-8', + 'text/plain', + 'Sat, 07 May 2016 16:54:48 GMT', + 'SAMEORIGIN', + 'en-US', + + // Invalid + 'Here is a value that is really a folded header value\r\n this should be \ + supported, but it is not currently', + '中文呢', // unicode + 'foo\nbar', + '\x7F' + ], + n: [5e8], +}); + +function main(conf) { + var n = +conf.n; + var key = conf.key; + + bench.start(); + for (var i = 0; i < n; i++) { + _checkInvalidHeaderChar(key); + } + bench.end(n); +} |