@@ -92,40 +92,38 @@ namespace ts.tracing {
9292 Emit = "emit" ,
9393 }
9494
95- export type EventData = [ phase : Phase , name : string , args ?: object ] ;
96-
97- /** Note: `push`/`pop` should be used by default.
98- * `begin`/`end` are for special cases where we need the data point even if the event never
99- * terminates (typically for reducing a scenario too big to trace to one that can be completed).
100- * In the future we might implement an exit handler to dump unfinished events which would
101- * deprecate these operations.
102- */
103- export function begin ( phase : Phase , name : string , args ?: object ) {
104- if ( ! traceFd ) return ;
105- writeEvent ( "B" , phase , name , args ) ;
106- }
107- export function end ( phase : Phase , name : string , args ?: object ) {
108- if ( ! traceFd ) return ;
109- writeEvent ( "E" , phase , name , args ) ;
110- }
111-
11295 export function instant ( phase : Phase , name : string , args ?: object ) {
11396 if ( ! traceFd ) return ;
11497 writeEvent ( "I" , phase , name , args , `"s":"g"` ) ;
11598 }
11699
117100 // Used for "Complete" (ph:"X") events
118- const completeEvents : { phase : Phase , name : string , args ?: object , time : number } [ ] = [ ] ;
119- export function push ( phase : Phase , name : string , args ?: object ) {
101+ const completeEvents : { phase : Phase , name : string , args ?: object , time : number , separateBeginAndEnd : boolean } [ ] = [ ] ;
102+
103+ /**
104+ * @param separateBeginAndEnd - used for special cases where we need the trace point even if the event
105+ * never terminates (typically for reducing a scenario too big to trace to one that can be completed).
106+ * In the future we might implement an exit handler to dump unfinished events which would deprecate
107+ * these operations.
108+ */
109+ export function push ( phase : Phase , name : string , args ?: object , separateBeginAndEnd = false ) {
120110 if ( ! traceFd ) return ;
121- completeEvents . push ( { phase, name, args, time : 1000 * timestamp ( ) } ) ;
111+ if ( separateBeginAndEnd ) {
112+ writeEvent ( "B" , phase , name , args ) ;
113+ }
114+ completeEvents . push ( { phase, name, args, time : 1000 * timestamp ( ) , separateBeginAndEnd } ) ;
122115 }
123116 export function pop ( ) {
124117 if ( ! traceFd ) return ;
125118 Debug . assert ( completeEvents . length > 0 ) ;
126- const { phase, name, args, time } = completeEvents . pop ( ) ! ;
127- const dur = 1000 * timestamp ( ) - time ;
128- writeEvent ( "X" , phase , name , args , `"dur":${ dur } ` , time ) ;
119+ const { phase, name, args, time, separateBeginAndEnd } = completeEvents . pop ( ) ! ;
120+ if ( separateBeginAndEnd ) {
121+ writeEvent ( "E" , phase , name , args ) ;
122+ }
123+ else {
124+ const dur = 1000 * timestamp ( ) - time ;
125+ writeEvent ( "X" , phase , name , args , `"dur":${ dur } ` , time ) ;
126+ }
129127 }
130128
131129 function writeEvent ( eventType : string , phase : Phase , name : string , args : object | undefined , extras ?: string ,
0 commit comments