File tree Expand file tree Collapse file tree 4 files changed +95
-2
lines changed Expand file tree Collapse file tree 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 {
6161} = internalBinding ( 'os' ) ;
6262
6363function getCheckedFunction ( fn ) {
64- return hideStackFrames ( function checkError ( ... args ) {
64+ return hideStackFrames ( function checkError ( ) {
6565 const ctx = { } ;
66- const ret = fn ( ... args , ctx ) ;
66+ const ret = fn ( ctx ) ;
6767 if ( ret === undefined ) {
6868 throw new ERR_SYSTEM_ERROR ( ctx ) ;
6969 }
You can’t perform that action at this time.
0 commit comments