diff options
Diffstat (limited to 'benchmark/fs')
-rw-r--r-- | benchmark/fs/bench-readdir.js | 11 | ||||
-rw-r--r-- | benchmark/fs/bench-readdirSync.js | 10 |
2 files changed, 14 insertions, 7 deletions
diff --git a/benchmark/fs/bench-readdir.js b/benchmark/fs/bench-readdir.js index a3e19e242d..0d8ed04856 100644 --- a/benchmark/fs/bench-readdir.js +++ b/benchmark/fs/bench-readdir.js @@ -5,16 +5,19 @@ const fs = require('fs'); const path = require('path'); const bench = common.createBenchmark(main, { - n: [1e4], + n: [10], + dir: [ 'lib', 'test/parallel'], + withFileTypes: ['true', 'false'] }); - -function main({ n }) { +function main({ n, dir, withFileTypes }) { + withFileTypes = withFileTypes === 'true'; + const fullPath = path.resolve(__dirname, '../../', dir); bench.start(); (function r(cntr) { if (cntr-- <= 0) return bench.end(n); - fs.readdir(path.resolve(__dirname, '../../lib/'), function() { + fs.readdir(fullPath, { withFileTypes }, function() { r(cntr); }); }(n)); diff --git a/benchmark/fs/bench-readdirSync.js b/benchmark/fs/bench-readdirSync.js index ef3327163e..5d0e97399a 100644 --- a/benchmark/fs/bench-readdirSync.js +++ b/benchmark/fs/bench-readdirSync.js @@ -5,14 +5,18 @@ const fs = require('fs'); const path = require('path'); const bench = common.createBenchmark(main, { - n: [1e4], + n: [10], + dir: [ 'lib', 'test/parallel'], + withFileTypes: ['true', 'false'] }); -function main({ n }) { +function main({ n, dir, withFileTypes }) { + withFileTypes = withFileTypes === 'true'; + const fullPath = path.resolve(__dirname, '../../', dir); bench.start(); for (var i = 0; i < n; i++) { - fs.readdirSync(path.resolve(__dirname, '../../lib/')); + fs.readdirSync(fullPath, { withFileTypes }); } bench.end(n); } |