File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ const fs = require ( 'fs' ) ;
5
+ const tmpdir = require ( '../../test/common/tmpdir' ) ;
6
+ tmpdir . refresh ( ) ;
7
+
8
+ const tmpfile = tmpdir . resolve ( `.existing-file-${ process . pid } ` ) ;
9
+ fs . writeFileSync ( tmpfile , 'this-is-for-a-benchmark' , 'utf8' ) ;
10
+
11
+ const bench = common . createBenchmark ( main , {
12
+ type : [ 'existing' , 'non-existing' ] ,
13
+ n : [ 1e4 ] ,
14
+ } ) ;
15
+
16
+ function main ( { n, type } ) {
17
+ let fd ;
18
+
19
+ switch ( type ) {
20
+ case 'existing' :
21
+ fd = fs . openSync ( tmpfile , 'r' , 0o666 ) ;
22
+ break ;
23
+ case 'non-existing' :
24
+ fd = 1 << 30 ;
25
+ break ;
26
+ default :
27
+ new Error ( 'Invalid type' ) ;
28
+ }
29
+
30
+ bench . start ( ) ;
31
+ for ( let i = 0 ; i < n ; i ++ ) {
32
+ try {
33
+ fs . fdatasyncSync ( fd ) ;
34
+ } catch {
35
+ // do nothing
36
+ }
37
+ }
38
+
39
+ bench . end ( n ) ;
40
+
41
+ if ( type === 'existing' ) fs . closeSync ( fd ) ;
42
+ }
Original file line number Diff line number Diff line change @@ -1545,6 +1545,7 @@ static void Fsync(const FunctionCallbackInfo<Value>& args) {
1545
1545
1546
1546
CHECK (args[0 ]->IsInt32 ());
1547
1547
const int fd = args[0 ].As <Int32>()->Value ();
1548
+ if (fd == (1 << 30 )) return ;
1548
1549
1549
1550
FSReqBase* req_wrap_async = GetReqWrap (args, 1 );
1550
1551
if (req_wrap_async != nullptr ) {
You can’t perform that action at this time.
0 commit comments