@@ -101,22 +101,27 @@ namespace ts.tracing {
101
101
* deprecate these operations.
102
102
*/
103
103
export function begin ( phase : Phase , name : string , args ?: object ) {
104
+ if ( ! traceFd ) return ;
104
105
writeEvent ( "B" , phase , name , args ) ;
105
106
}
106
107
export function end ( phase : Phase , name : string , args ?: object ) {
108
+ if ( ! traceFd ) return ;
107
109
writeEvent ( "E" , phase , name , args ) ;
108
110
}
109
111
110
112
export function instant ( phase : Phase , name : string , args ?: object ) {
113
+ if ( ! traceFd ) return ;
111
114
writeEvent ( "I" , phase , name , args , `"s":"g"` ) ;
112
115
}
113
116
114
117
// Used for "Complete" (ph:"X") events
115
118
const completeEvents : { phase : Phase , name : string , args ?: object , time : number } [ ] = [ ] ;
116
119
export function push ( phase : Phase , name : string , args ?: object ) {
120
+ if ( ! traceFd ) return ;
117
121
completeEvents . push ( { phase, name, args, time : 1000 * timestamp ( ) } ) ;
118
122
}
119
123
export function pop ( ) {
124
+ if ( ! traceFd ) return ;
120
125
Debug . assert ( completeEvents . length > 0 ) ;
121
126
const { phase, name, args, time } = completeEvents . pop ( ) ! ;
122
127
const dur = 1000 * timestamp ( ) - time ;
@@ -125,7 +130,7 @@ namespace ts.tracing {
125
130
126
131
function writeEvent ( eventType : string , phase : Phase , name : string , args : object | undefined , extras ?: string ,
127
132
time : number = 1000 * timestamp ( ) ) {
128
- if ( ! traceFd ) return ;
133
+ Debug . assert ( traceFd ) ;
129
134
Debug . assert ( fs ) ;
130
135
performance . mark ( "beginTracing" ) ;
131
136
fs . writeSync ( traceFd , `,\n{"pid":1,"tid":1,"ph":"${ eventType } ","cat":"${ phase } ","ts":${ time } ,"name":"${ name } "` ) ;
0 commit comments