@@ -60,6 +60,7 @@ import {
60
60
VariableStatement , walkUpParenthesizedExpressions , WriteFileCallback , WriteFileCallbackData ,
61
61
writeFileEnsuringDirectories , zipToModeAwareCache ,
62
62
} from "./_namespaces/ts" ;
63
+ import * as performance from "./_namespaces/ts.performance" ;
63
64
64
65
export function findConfigFile ( searchPath : string , fileExists : ( fileName : string ) => boolean , configName = "tsconfig.json" ) : string | undefined {
65
66
return forEachAncestorDirectory ( searchPath , ancestor => {
@@ -133,10 +134,10 @@ export function createGetSourceFile(
133
134
return ( fileName , languageVersionOrOptions , onError ) => {
134
135
let text : string | undefined ;
135
136
try {
136
- ts . performance . mark ( "beforeIORead" ) ;
137
+ performance . mark ( "beforeIORead" ) ;
137
138
text = readFile ( fileName , getCompilerOptions ( ) . charset ) ;
138
- ts . performance . mark ( "afterIORead" ) ;
139
- ts . performance . measure ( "I/O Read" , "beforeIORead" , "afterIORead" ) ;
139
+ performance . mark ( "afterIORead" ) ;
140
+ performance . measure ( "I/O Read" , "beforeIORead" , "afterIORead" ) ;
140
141
}
141
142
catch ( e ) {
142
143
if ( onError ) {
@@ -156,7 +157,7 @@ export function createWriteFileMeasuringIO(
156
157
) : CompilerHost [ "writeFile" ] {
157
158
return ( fileName , data , writeByteOrderMark , onError ) => {
158
159
try {
159
- ts . performance . mark ( "beforeIOWrite" ) ;
160
+ performance . mark ( "beforeIOWrite" ) ;
160
161
161
162
// NOTE: If patchWriteFileEnsuringDirectory has been called,
162
163
// the system.writeFile will do its own directory creation and
@@ -170,8 +171,8 @@ export function createWriteFileMeasuringIO(
170
171
directoryExists
171
172
) ;
172
173
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" ) ;
175
176
}
176
177
catch ( e ) {
177
178
if ( onError ) {
@@ -1142,7 +1143,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1142
1143
const sourceFilesFoundSearchingNodeModules = new Map < string , boolean > ( ) ;
1143
1144
1144
1145
tracing ?. push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
1145
- ts . performance . mark ( "beforeProgram" ) ;
1146
+ performance . mark ( "beforeProgram" ) ;
1146
1147
1147
1148
const host = createProgramOptions . host || createCompilerHost ( options ) ;
1148
1149
const configParsingHost = parseConfigHostFromCompilerHostLike ( host ) ;
@@ -1448,8 +1449,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1448
1449
} ) ;
1449
1450
1450
1451
verifyCompilerOptions ( ) ;
1451
- ts . performance . mark ( "afterProgram" ) ;
1452
- ts . performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1452
+ performance . mark ( "afterProgram" ) ;
1453
+ performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1453
1454
tracing ?. pop ( ) ;
1454
1455
1455
1456
return program ;
@@ -1489,10 +1490,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1489
1490
const containingFileName = getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) ;
1490
1491
const redirectedReference = getRedirectReferenceForResolution ( containingFile ) ;
1491
1492
tracing ?. push ( tracing . Phase . Program , "resolveModuleNamesWorker" , { containingFileName } ) ;
1492
- ts . performance . mark ( "beforeResolveModule" ) ;
1493
+ performance . mark ( "beforeResolveModule" ) ;
1493
1494
const result = actualResolveModuleNamesWorker ( moduleNames , containingFile , containingFileName , reusedNames , redirectedReference ) ;
1494
- ts . performance . mark ( "afterResolveModule" ) ;
1495
- ts . performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
1495
+ performance . mark ( "afterResolveModule" ) ;
1496
+ performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
1496
1497
tracing ?. pop ( ) ;
1497
1498
pullDiagnosticsFromCache ( moduleNames , containingFile ) ;
1498
1499
return result ;
@@ -1504,10 +1505,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1504
1505
const redirectedReference = ! isString ( containingFile ) ? getRedirectReferenceForResolution ( containingFile ) : undefined ;
1505
1506
const containingFileMode = ! isString ( containingFile ) ? containingFile . impliedNodeFormat : undefined ;
1506
1507
tracing ?. push ( tracing . Phase . Program , "resolveTypeReferenceDirectiveNamesWorker" , { containingFileName } ) ;
1507
- ts . performance . mark ( "beforeResolveTypeReference" ) ;
1508
+ performance . mark ( "beforeResolveTypeReference" ) ;
1508
1509
const result = actualResolveTypeReferenceDirectiveNamesWorker ( typeDirectiveNames , containingFileName , redirectedReference , containingFileMode ) ;
1509
- ts . performance . mark ( "afterResolveTypeReference" ) ;
1510
- ts . performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
1510
+ performance . mark ( "afterResolveTypeReference" ) ;
1511
+ performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
1511
1512
tracing ?. pop ( ) ;
1512
1513
return result ;
1513
1514
}
@@ -2052,7 +2053,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2052
2053
function emitBuildInfo ( writeFileCallback ?: WriteFileCallback ) : EmitResult {
2053
2054
Debug . assert ( ! outFile ( options ) ) ;
2054
2055
tracing ?. push ( tracing . Phase . Emit , "emitBuildInfo" , { } , /*separateBeginAndEnd*/ true ) ;
2055
- ts . performance . mark ( "beforeEmit" ) ;
2056
+ performance . mark ( "beforeEmit" ) ;
2056
2057
const emitResult = emitFiles (
2057
2058
notImplementedResolver ,
2058
2059
getEmitHost ( writeFileCallback ) ,
@@ -2062,8 +2063,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2062
2063
/*onlyBuildInfo*/ true
2063
2064
) ;
2064
2065
2065
- ts . performance . mark ( "afterEmit" ) ;
2066
- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2066
+ performance . mark ( "afterEmit" ) ;
2067
+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2067
2068
tracing ?. pop ( ) ;
2068
2069
return emitResult ;
2069
2070
}
@@ -2148,7 +2149,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2148
2149
// checked is to not pass the file to getEmitResolver.
2149
2150
const emitResolver = getTypeChecker ( ) . getEmitResolver ( outFile ( options ) ? undefined : sourceFile , cancellationToken ) ;
2150
2151
2151
- ts . performance . mark ( "beforeEmit" ) ;
2152
+ performance . mark ( "beforeEmit" ) ;
2152
2153
2153
2154
const emitResult = emitFiles (
2154
2155
emitResolver ,
@@ -2160,8 +2161,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2160
2161
forceDtsEmit
2161
2162
) ;
2162
2163
2163
- ts . performance . mark ( "afterEmit" ) ;
2164
- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2164
+ performance . mark ( "afterEmit" ) ;
2165
+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2165
2166
return emitResult ;
2166
2167
}
2167
2168
0 commit comments