Skip to content

Commit

Permalink
benchmark: add ClientRequest creation benchmark
Browse files Browse the repository at this point in the history
PR-URL: #10654
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  • Loading branch information
mscdex committed Jan 19, 2017
1 parent 5059b76 commit be24cc0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions benchmark/http/create-clientrequest.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit be24cc0

Please sign in to comment.