diff options
author | Brian White <mscdex@mscdex.net> | 2017-01-06 03:14:30 -0500 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2017-01-13 16:11:19 -0500 |
commit | c5d0fd9641b9cc4b6340a34dd75119d899a98017 (patch) | |
tree | 2b44ae27deafbf635d68ac18a6e717bc9ebe730a /benchmark/http | |
parent | 2f7759640ea7177d0bceb6f7aa68494c9ad1f2c1 (diff) | |
download | android-node-v8-c5d0fd9641b9cc4b6340a34dd75119d899a98017.tar.gz android-node-v8-c5d0fd9641b9cc4b6340a34dd75119d899a98017.tar.bz2 android-node-v8-c5d0fd9641b9cc4b6340a34dd75119d899a98017.zip |
benchmark: add ClientRequest creation benchmark
PR-URL: https://github.com/nodejs/node/pull/10654
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Diffstat (limited to 'benchmark/http')
-rw-r--r-- | benchmark/http/create-clientrequest.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/benchmark/http/create-clientrequest.js b/benchmark/http/create-clientrequest.js new file mode 100644 index 0000000000..76134663d0 --- /dev/null +++ b/benchmark/http/create-clientrequest.js @@ -0,0 +1,23 @@ +'use strict'; + +var common = require('../common.js'); +var ClientRequest = require('http').ClientRequest; + +var bench = common.createBenchmark(main, { + pathlen: [1, 8, 16, 32, 64, 128], + n: [1e6] +}); + +function main(conf) { + var pathlen = +conf.pathlen; + var n = +conf.n; + + var path = '/'.repeat(pathlen); + var opts = { path: path, createConnection: function() {} }; + + bench.start(); + for (var i = 0; i < n; i++) { + new ClientRequest(opts); + } + bench.end(n); +} |