@@ -59,6 +59,7 @@ import {
5959 VariableStatement , walkUpParenthesizedExpressions , WriteFileCallback , WriteFileCallbackData ,
6060 writeFileEnsuringDirectories , zipToModeAwareCache ,
6161} from "./_namespaces/ts" ;
62+ import * as performance from "./_namespaces/ts.performance" ;
6263
6364export function findConfigFile ( searchPath : string , fileExists : ( fileName : string ) => boolean , configName = "tsconfig.json" ) : string | undefined {
6465 return forEachAncestorDirectory ( searchPath , ancestor => {
@@ -130,10 +131,10 @@ export function createCompilerHostWorker(options: CompilerOptions, setParentNode
130131 function getSourceFile ( fileName : string , languageVersionOrOptions : ScriptTarget | CreateSourceFileOptions , onError ?: ( message : string ) => void ) : SourceFile | undefined {
131132 let text : string | undefined ;
132133 try {
133- ts . performance . mark ( "beforeIORead" ) ;
134+ performance . mark ( "beforeIORead" ) ;
134135 text = compilerHost . readFile ( fileName ) ;
135- ts . performance . mark ( "afterIORead" ) ;
136- ts . performance . measure ( "I/O Read" , "beforeIORead" , "afterIORead" ) ;
136+ performance . mark ( "afterIORead" ) ;
137+ performance . measure ( "I/O Read" , "beforeIORead" , "afterIORead" ) ;
137138 }
138139 catch ( e ) {
139140 if ( onError ) {
@@ -157,7 +158,7 @@ export function createCompilerHostWorker(options: CompilerOptions, setParentNode
157158
158159 function writeFile ( fileName : string , data : string , writeByteOrderMark : boolean , onError ?: ( message : string ) => void ) {
159160 try {
160- ts . performance . mark ( "beforeIOWrite" ) ;
161+ performance . mark ( "beforeIOWrite" ) ;
161162
162163 // NOTE: If patchWriteFileEnsuringDirectory has been called,
163164 // the system.writeFile will do its own directory creation and
@@ -170,8 +171,8 @@ export function createCompilerHostWorker(options: CompilerOptions, setParentNode
170171 path => ( compilerHost . createDirectory || system . createDirectory ) ( path ) ,
171172 path => directoryExists ( path ) ) ;
172173
173- ts . performance . mark ( "afterIOWrite" ) ;
174- ts . performance . measure ( "I/O Write" , "beforeIOWrite" , "afterIOWrite" ) ;
174+ performance . mark ( "afterIOWrite" ) ;
175+ performance . measure ( "I/O Write" , "beforeIOWrite" , "afterIOWrite" ) ;
175176 }
176177 catch ( e ) {
177178 if ( onError ) {
@@ -1118,7 +1119,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
11181119 const sourceFilesFoundSearchingNodeModules = new Map < string , boolean > ( ) ;
11191120
11201121 tracing ?. push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
1121- ts . performance . mark ( "beforeProgram" ) ;
1122+ performance . mark ( "beforeProgram" ) ;
11221123
11231124 const host = createProgramOptions . host || createCompilerHost ( options ) ;
11241125 const configParsingHost = parseConfigHostFromCompilerHostLike ( host ) ;
@@ -1424,8 +1425,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
14241425 } ) ;
14251426
14261427 verifyCompilerOptions ( ) ;
1427- ts . performance . mark ( "afterProgram" ) ;
1428- ts . performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1428+ performance . mark ( "afterProgram" ) ;
1429+ performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
14291430 tracing ?. pop ( ) ;
14301431
14311432 return program ;
@@ -1465,10 +1466,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
14651466 const containingFileName = getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) ;
14661467 const redirectedReference = getRedirectReferenceForResolution ( containingFile ) ;
14671468 tracing ?. push ( tracing . Phase . Program , "resolveModuleNamesWorker" , { containingFileName } ) ;
1468- ts . performance . mark ( "beforeResolveModule" ) ;
1469+ performance . mark ( "beforeResolveModule" ) ;
14691470 const result = actualResolveModuleNamesWorker ( moduleNames , containingFile , containingFileName , reusedNames , redirectedReference ) ;
1470- ts . performance . mark ( "afterResolveModule" ) ;
1471- ts . performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
1471+ performance . mark ( "afterResolveModule" ) ;
1472+ performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
14721473 tracing ?. pop ( ) ;
14731474 pullDiagnosticsFromCache ( moduleNames , containingFile ) ;
14741475 return result ;
@@ -1480,10 +1481,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
14801481 const redirectedReference = ! isString ( containingFile ) ? getRedirectReferenceForResolution ( containingFile ) : undefined ;
14811482 const containingFileMode = ! isString ( containingFile ) ? containingFile . impliedNodeFormat : undefined ;
14821483 tracing ?. push ( tracing . Phase . Program , "resolveTypeReferenceDirectiveNamesWorker" , { containingFileName } ) ;
1483- ts . performance . mark ( "beforeResolveTypeReference" ) ;
1484+ performance . mark ( "beforeResolveTypeReference" ) ;
14841485 const result = actualResolveTypeReferenceDirectiveNamesWorker ( typeDirectiveNames , containingFileName , redirectedReference , containingFileMode ) ;
1485- ts . performance . mark ( "afterResolveTypeReference" ) ;
1486- ts . performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
1486+ performance . mark ( "afterResolveTypeReference" ) ;
1487+ performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
14871488 tracing ?. pop ( ) ;
14881489 return result ;
14891490 }
@@ -2028,7 +2029,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
20282029 function emitBuildInfo ( writeFileCallback ?: WriteFileCallback ) : EmitResult {
20292030 Debug . assert ( ! outFile ( options ) ) ;
20302031 tracing ?. push ( tracing . Phase . Emit , "emitBuildInfo" , { } , /*separateBeginAndEnd*/ true ) ;
2031- ts . performance . mark ( "beforeEmit" ) ;
2032+ performance . mark ( "beforeEmit" ) ;
20322033 const emitResult = emitFiles (
20332034 notImplementedResolver ,
20342035 getEmitHost ( writeFileCallback ) ,
@@ -2038,8 +2039,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
20382039 /*onlyBuildInfo*/ true
20392040 ) ;
20402041
2041- ts . performance . mark ( "afterEmit" ) ;
2042- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2042+ performance . mark ( "afterEmit" ) ;
2043+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
20432044 tracing ?. pop ( ) ;
20442045 return emitResult ;
20452046 }
@@ -2123,7 +2124,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
21232124 // checked is to not pass the file to getEmitResolver.
21242125 const emitResolver = getTypeChecker ( ) . getEmitResolver ( outFile ( options ) ? undefined : sourceFile , cancellationToken ) ;
21252126
2126- ts . performance . mark ( "beforeEmit" ) ;
2127+ performance . mark ( "beforeEmit" ) ;
21272128
21282129 const emitResult = emitFiles (
21292130 emitResolver ,
@@ -2135,8 +2136,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
21352136 forceDtsEmit
21362137 ) ;
21372138
2138- ts . performance . mark ( "afterEmit" ) ;
2139- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2139+ performance . mark ( "afterEmit" ) ;
2140+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
21402141 return emitResult ;
21412142 }
21422143
0 commit comments