@@ -8,12 +8,12 @@ tmpdir.refresh();
88const bench = common . createBenchmark ( main , {
99 encoding : [ 'utf8' ] ,
1010 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' ] ,
1313 n : [ 1e3 ] ,
1414} ) ;
1515
16- function main ( { n, encoding, stringLength, hasFileDescriptor } ) {
16+ function main ( { n, func , encoding, stringLength, hasFileDescriptor } ) {
1717 tmpdir . refresh ( ) ;
1818 const enc = encoding === 'undefined' ? undefined : encoding ;
1919 const path = tmpdir . resolve ( `.writefilesync-file-${ Date . now ( ) } ` ) ;
@@ -23,9 +23,11 @@ function main({ n, encoding, stringLength, hasFileDescriptor }) {
2323
2424 const data = 'a' . repeat ( stringLength ) ;
2525
26+ const fn = fs [ func + 'Sync' ] ;
27+
2628 bench . start ( ) ;
2729 for ( let i = 0 ; i < n ; ++ i ) {
28- fs . writeFileSync ( file , data , enc ) ;
30+ fn ( file , data , enc ) ;
2931 }
3032 bench . end ( n ) ;
3133
0 commit comments