diff options
author | Seth Brenith <sethb@microsoft.com> | 2018-01-24 03:04:17 +0300 |
---|---|---|
committer | Jon Moss <me@jonathanmoss.me> | 2018-01-27 00:24:50 +0300 |
commit | aba6bc34a186ff03ff19a1b4026e04cea7c330e3 (patch) | |
tree | b79643e4c8ff478665c157112b5d7cdb59e95ffe /benchmark/http/set_header.js | |
parent | 6c1906ab3e0093a4f5c765de5a709abbe6b32d6b (diff) |
http: switch on string values
Long ago, V8 was much faster switching on string lengths than values.
That is no longer the case, so we can simplify a couple of methods.
PR-URL: https://github.com/nodejs/node/pull/18351
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Diffstat (limited to 'benchmark/http/set_header.js')
-rw-r--r-- | benchmark/http/set_header.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/benchmark/http/set_header.js b/benchmark/http/set_header.js new file mode 100644 index 00000000000..22de61b3f84 --- /dev/null +++ b/benchmark/http/set_header.js @@ -0,0 +1,30 @@ +'use strict'; + +const common = require('../common.js'); +const { OutgoingMessage } = require('_http_outgoing'); + +const bench = common.createBenchmark(main, { + value: [ + 'X-Powered-By', + 'Vary', + 'Set-Cookie', + 'Content-Type', + 'Content-Length', + 'Connection', + 'Transfer-Encoding' + ], + n: [1e6], +}); + +function main(conf) { + const n = +conf.n; + const value = conf.value; + + const og = new OutgoingMessage(); + + bench.start(); + for (var i = 0; i < n; i++) { + og.setHeader(value, ''); + } + bench.end(n); +} |