Skip to content

Commit

Permalink
benchmark: add cpSync benchmark
Browse files Browse the repository at this point in the history
PR-URL: nodejs#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 committed Jun 27, 2024
1 parent ad6d00e commit 895fcb0
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 895fcb0

Please sign in to comment.