@@ -8,12 +8,12 @@ tmpdir.refresh();
8
8
const bench = common . createBenchmark ( main , {
9
9
encoding : [ 'utf8' ] ,
10
10
hasFileDescriptor : [ 'true' , 'false' ] ,
11
- stringLength : [ 1024 , 4096 , 65535 ] ,
12
- // stringLength : [1024, 4096, 65535, 1024 * 1024 ],
11
+ stringLength : [ 1024 , 4096 , 65535 , 1024 * 1024 ] ,
12
+ func : [ 'writeFile' , 'appendFile' ] ,
13
13
n : [ 1e3 ] ,
14
14
} ) ;
15
15
16
- function main ( { n, encoding, stringLength, hasFileDescriptor } ) {
16
+ function main ( { n, func , encoding, stringLength, hasFileDescriptor } ) {
17
17
tmpdir . refresh ( ) ;
18
18
const enc = encoding === 'undefined' ? undefined : encoding ;
19
19
const path = tmpdir . resolve ( `.writefilesync-file-${ Date . now ( ) } ` ) ;
@@ -23,9 +23,11 @@ function main({ n, encoding, stringLength, hasFileDescriptor }) {
23
23
24
24
const data = 'a' . repeat ( stringLength ) ;
25
25
26
+ const fn = fs [ func + 'Sync' ] ;
27
+
26
28
bench . start ( ) ;
27
29
for ( let i = 0 ; i < n ; ++ i ) {
28
- fs . writeFileSync ( file , data , enc ) ;
30
+ fn ( file , data , enc ) ;
29
31
}
30
32
bench . end ( n ) ;
31
33
0 commit comments