summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-11-06 18:37:39 +0800
committerRich Trott <rtrott@gmail.com>2018-11-08 15:01:14 -0800
commitca51b9471ce2e031a569e49d6c6188e36f9a1b81 (patch)
treee62c9cda34b274092ce54a1f910fbd62161fccd2 /benchmark
parentc7e657908c4c2ade215ca51c04754b77489c760a (diff)
downloadandroid-node-v8-ca51b9471ce2e031a569e49d6c6188e36f9a1b81.tar.gz
android-node-v8-ca51b9471ce2e031a569e49d6c6188e36f9a1b81.tar.bz2
android-node-v8-ca51b9471ce2e031a569e49d6c6188e36f9a1b81.zip
benchmark: add dir and withFileTypes option readdir benchmarks
PR-URL: https://github.com/nodejs/node/pull/24125 Refs: https://github.com/v8/v8/commit/0483e9a9abe77a73632fd85b9c0cd608efa9aa0d Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/fs/bench-readdir.js11
-rw-r--r--benchmark/fs/bench-readdirSync.js10
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);
}