|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const common = require('../common'); |
| 4 | +const fs = require('fs'); |
| 5 | +const path = require('path'); |
| 6 | +const tmpdir = require('../../test/common/tmpdir'); |
| 7 | +tmpdir.refresh(); |
| 8 | + |
| 9 | +const bench = common.createBenchmark(main, { |
| 10 | +n: [1, 100, 10_000], |
| 11 | +}); |
| 12 | + |
| 13 | +function main({ n }) { |
| 14 | +tmpdir.refresh(); |
| 15 | +const options = { force: true, recursive: true }; |
| 16 | +const src = path.join(__dirname, '../../test/fixtures/copy'); |
| 17 | +const dest = tmpdir.resolve(`${process.pid}/subdir/cp-bench-${process.pid}`); |
| 18 | +bench.start(); |
| 19 | +for (let i = 0; i < n; i++) { |
| 20 | +fs.cpSync(src, dest, options); |
| 21 | +} |
| 22 | +bench.end(n); |
| 23 | +} |