File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 38
38
console . log ( "=====================================================================" ) ;
39
39
}
40
40
// Timeout is required to log info when importing from local installation
41
- setTimeout ( ( ) => {
41
+ setTimeout ( async ( ) => {
42
42
if ( ! process . env . UI5_CLI_NO_LOCAL ) {
43
43
const importLocal = require ( "import-local" ) ;
44
44
// Prefer a local installation of @ui 5/cli.
57
57
}
58
58
}
59
59
60
+ if ( process . env . UI5_CLI_PROFILE ) {
61
+ await ( require ( "../lib/utils/profile" ) . start ( ) ) ;
62
+ }
63
+
60
64
const updateNotifier = require ( "update-notifier" ) ;
61
65
updateNotifier ( {
62
66
pkg,
Original file line number Diff line number Diff line change @@ -69,4 +69,8 @@ cli.usage("Usage: ui5 <command> [options]")
69
69
console . log ( chalk . dim ( `See 'ui5 --help' or 'ui5 build --help' for help` ) ) ;
70
70
}
71
71
process . exit ( 1 ) ;
72
+ } ) . onFinishCommand ( async ( ) => {
73
+ if ( process . env . UI5_CLI_PROFILE ) {
74
+ await ( require ( "../../utils/profile" ) . stop ( ) ) ;
75
+ }
72
76
} ) ;
Original file line number Diff line number Diff line change
1
+ let session ;
2
+ const profile = {
3
+ start ( ) {
4
+ return new Promise ( ( resolve ) => {
5
+ if ( session ) {
6
+ resolve ( ) ;
7
+ return ;
8
+ }
9
+ const inspector = require ( "inspector" ) ;
10
+ session = new inspector . Session ( ) ;
11
+ session . connect ( ) ;
12
+ session . post ( "Profiler.enable" , ( ) => {
13
+ session . post ( "Profiler.start" , ( ) => {
14
+ resolve ( ) ;
15
+ } ) ;
16
+ } ) ;
17
+ } ) ;
18
+ } ,
19
+ stop ( ) {
20
+ if ( ! session ) {
21
+ return ;
22
+ }
23
+ session . post ( "Profiler.stop" , ( err , { profile} ) => {
24
+ if ( ! err ) {
25
+ require ( "fs" ) . writeFileSync ( `./ui5_${ Date . now ( ) . toString ( 36 ) } .cpuprofile` , JSON . stringify ( profile ) ) ;
26
+ }
27
+ } ) ;
28
+ }
29
+ } ;
30
+
31
+ module . exports = profile ;
You can’t perform that action at this time.
0 commit comments