benchmark: add cpSync benchmark

PR-URL: https://github.com/nodejs/node/pull/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>
pull/53826/head
Yagiz Nizipli 2024-06-27 17:13:21 -04:00 committed by Antoine du Hamel
parent 317a13b30f
commit 4d4a8338db
No known key found for this signature in database
GPG Key ID: 21D900FFDB233756
1 changed files with 23 additions and 0 deletions

View File

@ -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);
}