Permalink
Browse files

benchmark: add parameter for module benchmark

PR-URL: #10789
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information...
mscdex committed Jan 13, 2017
1 parent 99b27ce commit 190dc69c89b1d5ab3eb0e0c023a127752573acab
Showing with 20 additions and 7 deletions.
  1. +20 −7 benchmark/module/module-loader.js
@@ -8,7 +8,8 @@ var benchmarkDirectory = path.join(tmpDirectory, 'nodejs-benchmark-module');
var bench = common.createBenchmark(main, {
thousands: [50],
fullPath: ['true', 'false']
fullPath: ['true', 'false'],
useCache: ['true', 'false']
});
function main(conf) {
@@ -31,22 +32,34 @@ function main(conf) {
}
if (conf.fullPath === 'true')
measureFull(n);
measureFull(n, conf.useCache === 'true');
else
measureDir(n);
measureDir(n, conf.useCache === 'true');
}
function measureFull(n) {
function measureFull(n, useCache) {
var i;
if (useCache) {
for (i = 0; i <= n; i++) {
require(benchmarkDirectory + i + '/index.js');
}
}
bench.start();
for (var i = 0; i <= n; i++) {
for (i = 0; i <= n; i++) {
require(benchmarkDirectory + i + '/index.js');
}
bench.end(n / 1e3);
}
function measureDir(n) {
function measureDir(n, useCache) {
var i;
if (useCache) {
for (i = 0; i <= n; i++) {
require(benchmarkDirectory + i);
}
}
bench.start();
for (var i = 0; i <= n; i++) {
for (i = 0; i <= n; i++) {
require(benchmarkDirectory + i);
}
bench.end(n / 1e3);

0 comments on commit 190dc69

Please sign in to comment.