mirror of https://github.com/nodejs/node.git
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
parent
317a13b30f
commit
4d4a8338db
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue