Skip to content

Commit

Permalink
benchmark: add cpSync benchmark
Browse files Browse the repository at this point in the history
PR-URL: #53612
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
anonrig authored and marco-ippolito committed Aug 19, 2024
1 parent 8404421 commit c7e4c3d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions benchmark/fs/bench-cpSync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const common = require('../common');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();

const bench = common.createBenchmark(main, {
n: [1, 100, 10_000],
});

function main({ n }) {
tmpdir.refresh();
const options = { force: true, recursive: true };
const src = path.join(__dirname, '../../test/fixtures/copy');
const dest = tmpdir.resolve(`${process.pid}/subdir/cp-bench-${process.pid}`);
bench.start();
for (let i = 0; i < n; i++) {
fs.cpSync(src, dest, options);
}
bench.end(n);
}

0 comments on commit c7e4c3d

Please sign in to comment.