@@ -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 ) {
@@ -1122,7 +1123,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
11221123 const sourceFilesFoundSearchingNodeModules = new Map < string , boolean > ( ) ;
11231124
11241125 tracing ?. push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
1125- ts . performance . mark ( "beforeProgram" ) ;
1126+ performance . mark ( "beforeProgram" ) ;
11261127
11271128 const host = createProgramOptions . host || createCompilerHost ( options ) ;
11281129 const configParsingHost = parseConfigHostFromCompilerHostLike ( host ) ;
@@ -1428,8 +1429,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
14281429 } ) ;
14291430
14301431 verifyCompilerOptions ( ) ;
1431- ts . performance . mark ( "afterProgram" ) ;
1432- ts . performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1432+ performance . mark ( "afterProgram" ) ;
1433+ performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
14331434 tracing ?. pop ( ) ;
14341435
14351436 return program ;
@@ -1469,10 +1470,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
14691470 const containingFileName = getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) ;
14701471 const redirectedReference = getRedirectReferenceForResolution ( containingFile ) ;
14711472 tracing ?. push ( tracing . Phase . Program , "resolveModuleNamesWorker" , { containingFileName } ) ;
1472- ts . performance . mark ( "beforeResolveModule" ) ;
1473+ performance . mark ( "beforeResolveModule" ) ;
14731474 const result = actualResolveModuleNamesWorker ( moduleNames , containingFile , containingFileName , reusedNames , redirectedReference ) ;
1474- ts . performance . mark ( "afterResolveModule" ) ;
1475- ts . performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
1475+ performance . mark ( "afterResolveModule" ) ;
1476+ performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
14761477 tracing ?. pop ( ) ;
14771478 pullDiagnosticsFromCache ( moduleNames , containingFile ) ;
14781479 return result ;
@@ -1484,10 +1485,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
14841485 const redirectedReference = ! isString ( containingFile ) ? getRedirectReferenceForResolution ( containingFile ) : undefined ;
14851486 const containingFileMode = ! isString ( containingFile ) ? containingFile . impliedNodeFormat : undefined ;
14861487 tracing ?. push ( tracing . Phase . Program , "resolveTypeReferenceDirectiveNamesWorker" , { containingFileName } ) ;
1487- ts . performance . mark ( "beforeResolveTypeReference" ) ;
1488+ performance . mark ( "beforeResolveTypeReference" ) ;
14881489 const result = actualResolveTypeReferenceDirectiveNamesWorker ( typeDirectiveNames , containingFileName , redirectedReference , containingFileMode ) ;
1489- ts . performance . mark ( "afterResolveTypeReference" ) ;
1490- ts . performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
1490+ performance . mark ( "afterResolveTypeReference" ) ;
1491+ performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
14911492 tracing ?. pop ( ) ;
14921493 return result ;
14931494 }
@@ -2032,7 +2033,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
20322033 function emitBuildInfo ( writeFileCallback ?: WriteFileCallback ) : EmitResult {
20332034 Debug . assert ( ! outFile ( options ) ) ;
20342035 tracing ?. push ( tracing . Phase . Emit , "emitBuildInfo" , { } , /*separateBeginAndEnd*/ true ) ;
2035- ts . performance . mark ( "beforeEmit" ) ;
2036+ performance . mark ( "beforeEmit" ) ;
20362037 const emitResult = emitFiles (
20372038 notImplementedResolver ,
20382039 getEmitHost ( writeFileCallback ) ,
@@ -2042,8 +2043,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
20422043 /*onlyBuildInfo*/ true
20432044 ) ;
20442045
2045- ts . performance . mark ( "afterEmit" ) ;
2046- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2046+ performance . mark ( "afterEmit" ) ;
2047+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
20472048 tracing ?. pop ( ) ;
20482049 return emitResult ;
20492050 }
@@ -2127,7 +2128,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
21272128 // checked is to not pass the file to getEmitResolver.
21282129 const emitResolver = getTypeChecker ( ) . getEmitResolver ( outFile ( options ) ? undefined : sourceFile , cancellationToken ) ;
21292130
2130- ts . performance . mark ( "beforeEmit" ) ;
2131+ performance . mark ( "beforeEmit" ) ;
21312132
21322133 const emitResult = emitFiles (
21332134 emitResolver ,
@@ -2139,8 +2140,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
21392140 forceDtsEmit
21402141 ) ;
21412142
2142- ts . performance . mark ( "afterEmit" ) ;
2143- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2143+ performance . mark ( "afterEmit" ) ;
2144+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
21442145 return emitResult ;
21452146 }
21462147
0 commit comments