@@ -101,22 +101,27 @@ namespace ts.tracing {
101101 * deprecate these operations.
102102 */
103103 export function begin ( phase : Phase , name : string , args ?: object ) {
104+ if ( ! traceFd ) return ;
104105 writeEvent ( "B" , phase , name , args ) ;
105106 }
106107 export function end ( phase : Phase , name : string , args ?: object ) {
108+ if ( ! traceFd ) return ;
107109 writeEvent ( "E" , phase , name , args ) ;
108110 }
109111
110112 export function instant ( phase : Phase , name : string , args ?: object ) {
113+ if ( ! traceFd ) return ;
111114 writeEvent ( "I" , phase , name , args , `"s":"g"` ) ;
112115 }
113116
114117 // Used for "Complete" (ph:"X") events
115118 const completeEvents : { phase : Phase , name : string , args ?: object , time : number } [ ] = [ ] ;
116119 export function push ( phase : Phase , name : string , args ?: object ) {
120+ if ( ! traceFd ) return ;
117121 completeEvents . push ( { phase, name, args, time : 1000 * timestamp ( ) } ) ;
118122 }
119123 export function pop ( ) {
124+ if ( ! traceFd ) return ;
120125 Debug . assert ( completeEvents . length > 0 ) ;
121126 const { phase, name, args, time } = completeEvents . pop ( ) ! ;
122127 const dur = 1000 * timestamp ( ) - time ;
@@ -125,7 +130,7 @@ namespace ts.tracing {
125130
126131 function writeEvent ( eventType : string , phase : Phase , name : string , args : object | undefined , extras ?: string ,
127132 time : number = 1000 * timestamp ( ) ) {
128- if ( ! traceFd ) return ;
133+ Debug . assert ( traceFd ) ;
129134 Debug . assert ( fs ) ;
130135 performance . mark ( "beginTracing" ) ;
131136 fs . writeSync ( traceFd , `,\n{"pid":1,"tid":1,"ph":"${ eventType } ","cat":"${ phase } ","ts":${ time } ,"name":"${ name } "` ) ;
0 commit comments