File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,14 +10,26 @@ const fn = () => {
1010 return a ;
1111} ;
1212
13+ console . log ( ) ;
14+
1315console . time ( 'experiment' ) ;
1416const res1 = fn ( ) ;
15- console . log ( res1 . length ) ;
17+ console . log ( 'res1.length' , res1 . length ) ;
1618console . timeEnd ( 'experiment' ) ;
1719
18- const begin = process . hrtime ( ) ;
20+ console . log ( ) ;
21+
22+ const begin2 = new Date ( ) . getTime ( ) ;
1923const res2 = fn ( ) ;
20- console . log ( res2 . length ) ;
21- const end = process . hrtime ( begin ) ;
22- const diff = end [ 0 ] * 1e9 + end [ 1 ] ;
23- console . log ( diff + ' nanoseconds' ) ;
24+ const end2 = new Date ( ) . getTime ( ) ;
25+ const diff2 = end2 - begin2 ;
26+ console . dir ( { length : res2 . length , diff : diff2 } ) ;
27+
28+ console . log ( ) ;
29+
30+ const begin3 = process . hrtime ( ) ;
31+ const res3 = fn ( ) ;
32+ const end3 = process . hrtime ( begin3 ) ;
33+ const diff3 = end3 [ 0 ] * 1e9 + end3 [ 1 ] ;
34+ const sec3 = diff3 / 1e9 ;
35+ console . dir ( { length : res3 . length , msec : diff3 , sec : sec3 } ) ;
You can’t perform that action at this time.
0 commit comments