Skip to content

Commit 332f738

Browse files
mscdexMyles Borins
authored andcommitted
benchmark: add module loader benchmark parameter
PR-URL: #5172 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8ae200c commit 332f738

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

‎benchmark/module/module-loader.js‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ var tmpDirectory = path.join(__dirname, '..', 'tmp');
77
varbenchmarkDirectory=path.join(tmpDirectory,'nodejs-benchmark-module');
88

99
varbench=common.createBenchmark(main,{
10-
thousands: [50]
10+
thousands: [50],
11+
fullPath: ['true','false']
1112
});
1213

1314
functionmain(conf){
15+
varn=+conf.thousands*1e3;
16+
1417
rmrf(tmpDirectory);
1518
try{fs.mkdirSync(tmpDirectory);}catch(e){}
1619
try{fs.mkdirSync(benchmarkDirectory);}catch(e){}
1720

18-
varn=+conf.thousands*1e3;
1921
for(vari=0;i<=n;i++){
2022
fs.mkdirSync(benchmarkDirectory+i);
2123
fs.writeFileSync(
@@ -28,10 +30,21 @@ function main(conf) {
2830
);
2931
}
3032

31-
measure(n);
33+
if(conf.fullPath==='true')
34+
measureFull(n);
35+
else
36+
measureDir(n);
37+
}
38+
39+
functionmeasureFull(n){
40+
bench.start();
41+
for(vari=0;i<=n;i++){
42+
require(benchmarkDirectory+i+'/index.js');
43+
}
44+
bench.end(n/1e3);
3245
}
3346

34-
functionmeasure(n){
47+
functionmeasureDir(n){
3548
bench.start();
3649
for(vari=0;i<=n;i++){
3750
require(benchmarkDirectory+i);

0 commit comments

Comments
 (0)