GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — benchmark: add access async version to bench · nodejs/node@237d7df

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/fs
    • bench-accessSync.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/fs/bench-accessSync.js‎

Copy file name to clipboardExpand all lines: benchmark/fs/bench-accessSync.js
+26-6Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ fs.writeFileSync(tmpfile, 'this-is-for-a-benchmark', 'utf8');
1010

1111
const bench = common.createBenchmark(main, {
1212
type: ['existing', 'non-existing', 'non-flat-existing'],
13+
method: ['access', 'accessSync'],
1314
n: [1e5],
1415
});
1516

@@ -23,7 +24,17 @@ function runBench(n, path) {
2324
}
2425
}
2526

26-
function main({ n, type }) {
27+
function runAsyncBench(n, path) {
28+
(function r(cntr, path) {
29+
if (cntr-- <= 0)
30+
return bench.end(n);
31+
fs.access(path, () => {
32+
r(cntr, path);
33+
});
34+
})(n, path);
35+
}
36+
37+
function main({ n, type, method }) {
2738
let path;
2839

2940
switch (type) {
@@ -39,10 +50,19 @@ function main({ n, type }) {
3950
default:
4051
new Error('Invalid type');
4152
}
42-
// warmup
43-
runBench(n, path);
4453

45-
bench.start();
46-
runBench(n, path);
47-
bench.end(n);
54+
if (method === 'access') {
55+
// Warmup the filesystem - it doesn't need to use the async method
56+
runBench(n, path);
57+
58+
bench.start();
59+
runAsyncBench(n, path);
60+
} else {
61+
// warmup
62+
runBench(n, path);
63+
64+
bench.start();
65+
runBench(n, path);
66+
bench.end(n);
67+
}
4868
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.