benchmark: add parameter for module benchmark
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
99b27ce99a
commit
190dc69c89
@ -8,7 +8,8 @@ var benchmarkDirectory = path.join(tmpDirectory, 'nodejs-benchmark-module');
|
|||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
var bench = common.createBenchmark(main, {
|
||||||
thousands: [50],
|
thousands: [50],
|
||||||
fullPath: ['true', 'false']
|
fullPath: ['true', 'false'],
|
||||||
|
useCache: ['true', 'false']
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
@ -31,22 +32,34 @@ function main(conf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (conf.fullPath === 'true')
|
if (conf.fullPath === 'true')
|
||||||
measureFull(n);
|
measureFull(n, conf.useCache === 'true');
|
||||||
else
|
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();
|
bench.start();
|
||||||
for (var i = 0; i <= n; i++) {
|
for (i = 0; i <= n; i++) {
|
||||||
require(benchmarkDirectory + i + '/index.js');
|
require(benchmarkDirectory + i + '/index.js');
|
||||||
}
|
}
|
||||||
bench.end(n / 1e3);
|
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();
|
bench.start();
|
||||||
for (var i = 0; i <= n; i++) {
|
for (i = 0; i <= n; i++) {
|
||||||
require(benchmarkDirectory + i);
|
require(benchmarkDirectory + i);
|
||||||
}
|
}
|
||||||
bench.end(n / 1e3);
|
bench.end(n / 1e3);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user