summaryrefslogtreecommitdiff
path: root/benchmark/module
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2016-02-10 03:58:58 -0500
committerBrian White <mscdex@mscdex.net>2016-04-14 14:56:27 -0400
commit1e4674ae0aec78f32c26a297ac11b45d46c24344 (patch)
tree53c2ac185b2c68c003783a59e4cae1fbaf2c99eb /benchmark/module
parent1df84f4f75843ad01d95dc55d63ba30b2b69fbd4 (diff)
downloadandroid-node-v8-1e4674ae0aec78f32c26a297ac11b45d46c24344.tar.gz
android-node-v8-1e4674ae0aec78f32c26a297ac11b45d46c24344.tar.bz2
android-node-v8-1e4674ae0aec78f32c26a297ac11b45d46c24344.zip
benchmark: add module loader benchmark parameter
PR-URL: https://github.com/nodejs/node/pull/5172 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/module')
-rw-r--r--benchmark/module/module-loader.js21
1 files changed, 17 insertions, 4 deletions
diff --git a/benchmark/module/module-loader.js b/benchmark/module/module-loader.js
index 1df7a74cbe..a175533c7b 100644
--- a/benchmark/module/module-loader.js
+++ b/benchmark/module/module-loader.js
@@ -7,15 +7,17 @@ var tmpDirectory = path.join(__dirname, '..', 'tmp');
var benchmarkDirectory = path.join(tmpDirectory, 'nodejs-benchmark-module');
var bench = common.createBenchmark(main, {
- thousands: [50]
+ thousands: [50],
+ fullPath: ['true', 'false']
});
function main(conf) {
+ var n = +conf.thousands * 1e3;
+
rmrf(tmpDirectory);
try { fs.mkdirSync(tmpDirectory); } catch (e) {}
try { fs.mkdirSync(benchmarkDirectory); } catch (e) {}
- var n = +conf.thousands * 1e3;
for (var i = 0; i <= n; i++) {
fs.mkdirSync(benchmarkDirectory + i);
fs.writeFileSync(
@@ -28,10 +30,21 @@ function main(conf) {
);
}
- measure(n);
+ if (conf.fullPath === 'true')
+ measureFull(n);
+ else
+ measureDir(n);
+}
+
+function measureFull(n) {
+ bench.start();
+ for (var i = 0; i <= n; i++) {
+ require(benchmarkDirectory + i + '/index.js');
+ }
+ bench.end(n / 1e3);
}
-function measure(n) {
+function measureDir(n) {
bench.start();
for (var i = 0; i <= n; i++) {
require(benchmarkDirectory + i);