Commit c25716b 1 parent e60b3ab commit c25716b Copy full SHA for c25716b
File tree 4 files changed +95
-2
lines changed
4 files changed +95
-2
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common.js' ) ;
4
+ const homedir = require ( 'os' ) . homedir ;
5
+ const assert = require ( 'assert' ) ;
6
+
7
+ const bench = common . createBenchmark ( main , {
8
+ n : [ 1e6 ] ,
9
+ } ) ;
10
+
11
+ function main ( { n } ) {
12
+ // Warm up.
13
+ const length = 1024 ;
14
+ const array = [ ] ;
15
+ for ( let i = 0 ; i < length ; ++ i ) {
16
+ array . push ( homedir ( ) ) ;
17
+ }
18
+
19
+ bench . start ( ) ;
20
+ for ( let i = 0 ; i < n ; ++ i ) {
21
+ const index = i % length ;
22
+ array [ index ] = homedir ( ) ;
23
+ }
24
+ bench . end ( n ) ;
25
+
26
+ // Verify the entries to prevent dead code elimination from making
27
+ // the benchmark invalid.
28
+ for ( let i = 0 ; i < length ; ++ i ) {
29
+ assert . strictEqual ( typeof array [ i ] , 'string' ) ;
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common.js' ) ;
4
+ const hostname = require ( 'os' ) . hostname ;
5
+ const assert = require ( 'assert' ) ;
6
+
7
+ const bench = common . createBenchmark ( main , {
8
+ n : [ 1e6 ] ,
9
+ } ) ;
10
+
11
+ function main ( { n } ) {
12
+ // Warm up.
13
+ const length = 1024 ;
14
+ const array = [ ] ;
15
+ for ( let i = 0 ; i < length ; ++ i ) {
16
+ array . push ( hostname ( ) ) ;
17
+ }
18
+
19
+ bench . start ( ) ;
20
+ for ( let i = 0 ; i < n ; ++ i ) {
21
+ const index = i % length ;
22
+ array [ index ] = hostname ( ) ;
23
+ }
24
+ bench . end ( n ) ;
25
+
26
+ // Verify the entries to prevent dead code elimination from making
27
+ // the benchmark invalid.
28
+ for ( let i = 0 ; i < length ; ++ i ) {
29
+ assert . strictEqual ( typeof array [ i ] , 'string' ) ;
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common.js' ) ;
4
+ const uptime = require ( 'os' ) . uptime ;
5
+ const assert = require ( 'assert' ) ;
6
+
7
+ const bench = common . createBenchmark ( main , {
8
+ n : [ 1e5 ] ,
9
+ } ) ;
10
+
11
+ function main ( { n } ) {
12
+ // Warm up.
13
+ const length = 1024 ;
14
+ const array = [ ] ;
15
+ for ( let i = 0 ; i < length ; ++ i ) {
16
+ array . push ( uptime ( ) ) ;
17
+ }
18
+
19
+ bench . start ( ) ;
20
+ for ( let i = 0 ; i < n ; ++ i ) {
21
+ const index = i % length ;
22
+ array [ index ] = uptime ( ) ;
23
+ }
24
+ bench . end ( n ) ;
25
+
26
+ // Verify the entries to prevent dead code elimination from making
27
+ // the benchmark invalid.
28
+ for ( let i = 0 ; i < length ; ++ i ) {
29
+ assert . strictEqual ( typeof array [ i ] , 'number' ) ;
30
+ }
31
+ }
Original file line number Diff line number Diff line change @@ -61,9 +61,9 @@ const {
61
61
} = internalBinding ( 'os' ) ;
62
62
63
63
function getCheckedFunction ( fn ) {
64
- return hideStackFrames ( function checkError ( ... args ) {
64
+ return hideStackFrames ( function checkError ( ) {
65
65
const ctx = { } ;
66
- const ret = fn ( ... args , ctx ) ;
66
+ const ret = fn ( ctx ) ;
67
67
if ( ret === undefined ) {
68
68
throw new ERR_SYSTEM_ERROR ( ctx ) ;
69
69
}
You can’t perform that action at this time.
0 commit comments