node/benchmark/http/create-clientrequest.js
Joyee Cheung 3e3414f45f benchmark: control HTTP benchmarks run time
PR-URL: https://github.com/nodejs/node/pull/12121
Refs: https://github.com/nodejs/node/issues/12068
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-09 18:16:08 +08:00

24 lines
454 B
JavaScript

'use strict';
var common = require('../common.js');
var ClientRequest = require('http').ClientRequest;
var bench = common.createBenchmark(main, {
len: [1, 8, 16, 32, 64, 128],
n: [1e6]
});
function main(conf) {
var len = +conf.len;
var n = +conf.n;
var path = '/'.repeat(len);
var opts = { path: path, createConnection: function() {} };
bench.start();
for (var i = 0; i < n; i++) {
new ClientRequest(opts);
}
bench.end(n);
}