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 3838 console . log ( "=====================================================================" ) ;
3939 }
4040 // Timeout is required to log info when importing from local installation
41- setTimeout ( ( ) => {
41+ setTimeout ( async ( ) => {
4242 if ( ! process . env . UI5_CLI_NO_LOCAL ) {
4343 const importLocal = require ( "import-local" ) ;
4444 // Prefer a local installation of @ui 5/cli.
5757 }
5858 }
5959
60+ if ( process . env . UI5_CLI_PROFILE ) {
61+ await ( require ( "../lib/utils/profile" ) . start ( ) ) ;
62+ }
63+
6064 const updateNotifier = require ( "update-notifier" ) ;
6165 updateNotifier ( {
6266 pkg,
Original file line number Diff line number Diff line change @@ -69,4 +69,8 @@ cli.usage("Usage: ui5 <command> [options]")
6969 console . log ( chalk . dim ( `See 'ui5 --help' or 'ui5 build --help' for help` ) ) ;
7070 }
7171 process . exit ( 1 ) ;
72+ } ) . onFinishCommand ( async ( ) => {
73+ if ( process . env . UI5_CLI_PROFILE ) {
74+ await ( require ( "../../utils/profile" ) . stop ( ) ) ;
75+ }
7276 } ) ;
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