mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 05:25:19 +00:00
benchmark: add a warmup on bench-openSync
PR-URL: https://github.com/nodejs/node/pull/57051 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Raz Luvaton <rluvaton@gmail.com>
This commit is contained in:
parent
b6cd6b7e31
commit
610e474728
@ -10,6 +10,18 @@ const bench = common.createBenchmark(main, {
|
||||
n: [1e5],
|
||||
});
|
||||
|
||||
function runBench({ n, path }) {
|
||||
for (let i = 0; i < n; i++) {
|
||||
try {
|
||||
const fd = fs.openSync(path, 'r', 0o666);
|
||||
fs.closeSync(fd);
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function main({ n, type }) {
|
||||
let path;
|
||||
|
||||
@ -24,14 +36,9 @@ function main({ n, type }) {
|
||||
new Error('Invalid type');
|
||||
}
|
||||
|
||||
runBench({ n, path });
|
||||
|
||||
bench.start();
|
||||
for (let i = 0; i < n; i++) {
|
||||
try {
|
||||
const fd = fs.openSync(path, 'r', 0o666);
|
||||
fs.closeSync(fd);
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
runBench({ n, path });
|
||||
bench.end(n);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user