diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-01-26 00:09:55 +0800 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-02-01 11:43:30 +0100 |
commit | 54b3a685c198a7b2c277c2a223041ec203375358 (patch) | |
tree | 71989b34d2d3b1493e836c5e7defd297db6ba4bf /benchmark/http/set-header.js | |
parent | 2d6912a46bf6f56a4f7b1d354680ad318cc7a153 (diff) | |
download | android-node-v8-54b3a685c198a7b2c277c2a223041ec203375358.tar.gz android-node-v8-54b3a685c198a7b2c277c2a223041ec203375358.tar.bz2 android-node-v8-54b3a685c198a7b2c277c2a223041ec203375358.zip |
benchmark: cut down http benchmark run time
PR-URL: https://github.com/nodejs/node/pull/18379
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'benchmark/http/set-header.js')
-rw-r--r-- | benchmark/http/set-header.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/benchmark/http/set-header.js b/benchmark/http/set-header.js new file mode 100644 index 0000000000..f0987f2cc7 --- /dev/null +++ b/benchmark/http/set-header.js @@ -0,0 +1,32 @@ +'use strict'; +const common = require('../common.js'); +const PORT = common.PORT; + +const bench = common.createBenchmark(main, { + res: ['normal', 'setHeader', 'setHeaderWH'] +}); + +const type = 'bytes'; +const len = 4; +const chunks = 0; +const chunkedEnc = 0; +const c = 50; + +// normal: writeHead(status, {...}) +// setHeader: statusCode = status, setHeader(...) x2 +// setHeaderWH: setHeader(...), writeHead(status, ...) +function main({ res }) { + process.env.PORT = PORT; + var server = require('../fixtures/simple-http-server.js') + .listen(PORT) + .on('listening', function() { + const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`; + + bench.http({ + path: path, + connections: c + }, function() { + server.close(); + }); + }); +} |