We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9de45cb commit f4a82fdCopy full SHA for f4a82fd
benchmark/fs/bench-openSync.js
@@ -10,6 +10,18 @@ const bench = common.createBenchmark(main, {
10
n: [1e5],
11
});
12
13
+function runBench({ n, path }) {
14
+ for (let i = 0; i < n; i++) {
15
+ try {
16
+ const fd = fs.openSync(path, 'r', 0o666);
17
+ fs.closeSync(fd);
18
+ } catch {
19
+ // do nothing
20
+ }
21
22
+}
23
+
24
25
function main({ n, type }) {
26
let path;
27
@@ -24,14 +36,9 @@ function main({ n, type }) {
36
new Error('Invalid type');
37
}
38
39
+ runBench({ n, path });
40
41
bench.start();
28
- for (let i = 0; i < n; i++) {
29
- try {
30
- const fd = fs.openSync(path, 'r', 0o666);
31
- fs.closeSync(fd);
32
- } catch {
33
- // do nothing
34
- }
35
42
43
bench.end(n);
44
0 commit comments