Skip to content

Commit c7e4c3d

Browse files
anonrigmarco-ippolito
authored andcommitted
benchmark: add cpSync benchmark
PR-URL: #53612 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 8404421 commit c7e4c3d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

benchmark/fs/bench-cpSync.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const fs = require('fs');
5+
const path = require('path');
6+
const tmpdir = require('../../test/common/tmpdir');
7+
tmpdir.refresh();
8+
9+
const bench = common.createBenchmark(main, {
10+
n: [1, 100, 10_000],
11+
});
12+
13+
function main({ n }) {
14+
tmpdir.refresh();
15+
const options = { force: true, recursive: true };
16+
const src = path.join(__dirname, '../../test/fixtures/copy');
17+
const dest = tmpdir.resolve(`${process.pid}/subdir/cp-bench-${process.pid}`);
18+
bench.start();
19+
for (let i = 0; i < n; i++) {
20+
fs.cpSync(src, dest, options);
21+
}
22+
bench.end(n);
23+
}

0 commit comments

Comments
 (0)