Skip to content

Commit c5d0fd9

Browse files
committed
benchmark: add ClientRequest creation benchmark
PR-URL: #10654 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
1 parent 2f77596 commit c5d0fd9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
var common = require('../common.js');
4+
var ClientRequest = require('http').ClientRequest;
5+
6+
var bench = common.createBenchmark(main, {
7+
pathlen: [1, 8, 16, 32, 64, 128],
8+
n: [1e6]
9+
});
10+
11+
function main(conf) {
12+
var pathlen = +conf.pathlen;
13+
var n = +conf.n;
14+
15+
var path = '/'.repeat(pathlen);
16+
var opts = { path: path, createConnection: function() {} };
17+
18+
bench.start();
19+
for (var i = 0; i < n; i++) {
20+
new ClientRequest(opts);
21+
}
22+
bench.end(n);
23+
}

0 commit comments

Comments
 (0)