Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force defaults to true.

Suggested change
const options = { force: true, recursive: true };
const options = { recursive: true };

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Will merge this since this is not a blocking review, but I'll definitely update this once I have the change to improve this benchmark.

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