Skip to content

Commit 4d4a833

Browse files
anonrigaduh95
authored andcommitted
benchmark: add cpSync benchmark
PR-URL: #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>
1 parent 317a13b commit 4d4a833

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎benchmark/fs/bench-cpSync.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
constcommon=require('../common');
4+
constfs=require('fs');
5+
constpath=require('path');
6+
consttmpdir=require('../../test/common/tmpdir');
7+
tmpdir.refresh();
8+
9+
constbench=common.createBenchmark(main,{
10+
n: [1,100,10_000],
11+
});
12+
13+
functionmain({ n }){
14+
tmpdir.refresh();
15+
constoptions={force: true,recursive: true};
16+
constsrc=path.join(__dirname,'../../test/fixtures/copy');
17+
constdest=tmpdir.resolve(`${process.pid}/subdir/cp-bench-${process.pid}`);
18+
bench.start();
19+
for(leti=0;i<n;i++){
20+
fs.cpSync(src,dest,options);
21+
}
22+
bench.end(n);
23+
}

0 commit comments

Comments
 (0)