diff options
author | Brian White <mscdex@mscdex.net> | 2017-01-13 05:02:45 -0500 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2017-03-10 23:46:36 -0500 |
commit | 190dc69c89b1d5ab3eb0e0c023a127752573acab (patch) | |
tree | 18e60dff979bc8469aba7887d443073ad4bd509a /benchmark/module | |
parent | 99b27ce99a8bdd6bc733cde36a144a82cfea0b98 (diff) | |
download | node-new-190dc69c89b1d5ab3eb0e0c023a127752573acab.tar.gz |
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>
Diffstat (limited to 'benchmark/module')
-rw-r--r-- | benchmark/module/module-loader.js | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/benchmark/module/module-loader.js b/benchmark/module/module-loader.js index a175533c7b..090f7b7854 100644 --- a/benchmark/module/module-loader.js +++ b/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); |