@@ -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 ) {
@@ -1145,7 +1146,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1145
1146
const sourceFilesFoundSearchingNodeModules = new Map < string , boolean > ( ) ;
1146
1147
1147
1148
tracing ?. push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
1148
- ts . performance . mark ( "beforeProgram" ) ;
1149
+ performance . mark ( "beforeProgram" ) ;
1149
1150
1150
1151
const host = createProgramOptions . host || createCompilerHost ( options ) ;
1151
1152
const configParsingHost = parseConfigHostFromCompilerHostLike ( host ) ;
@@ -1468,8 +1469,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1468
1469
} ) ;
1469
1470
1470
1471
verifyCompilerOptions ( ) ;
1471
- ts . performance . mark ( "afterProgram" ) ;
1472
- ts . performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1472
+ performance . mark ( "afterProgram" ) ;
1473
+ performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1473
1474
tracing ?. pop ( ) ;
1474
1475
1475
1476
return program ;
@@ -1506,10 +1507,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1506
1507
const containingFileName = getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) ;
1507
1508
const redirectedReference = getRedirectReferenceForResolution ( containingFile ) ;
1508
1509
tracing ?. push ( tracing . Phase . Program , "resolveModuleNamesWorker" , { containingFileName } ) ;
1509
- ts . performance . mark ( "beforeResolveModule" ) ;
1510
+ performance . mark ( "beforeResolveModule" ) ;
1510
1511
const result = actualResolveModuleNamesWorker ( moduleNames , containingFile , containingFileName , redirectedReference , resolutionInfo ) ;
1511
- ts . performance . mark ( "afterResolveModule" ) ;
1512
- ts . performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
1512
+ performance . mark ( "afterResolveModule" ) ;
1513
+ performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
1513
1514
tracing ?. pop ( ) ;
1514
1515
pullDiagnosticsFromCache ( moduleNames , containingFile ) ;
1515
1516
return result ;
@@ -1521,10 +1522,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1521
1522
const redirectedReference = ! isString ( containingFile ) ? getRedirectReferenceForResolution ( containingFile ) : undefined ;
1522
1523
const containingFileMode = ! isString ( containingFile ) ? containingFile . impliedNodeFormat : undefined ;
1523
1524
tracing ?. push ( tracing . Phase . Program , "resolveTypeReferenceDirectiveNamesWorker" , { containingFileName } ) ;
1524
- ts . performance . mark ( "beforeResolveTypeReference" ) ;
1525
+ performance . mark ( "beforeResolveTypeReference" ) ;
1525
1526
const result = actualResolveTypeReferenceDirectiveNamesWorker ( typeDirectiveNames , containingFileName , redirectedReference , containingFileMode ) ;
1526
- ts . performance . mark ( "afterResolveTypeReference" ) ;
1527
- ts . performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
1527
+ performance . mark ( "afterResolveTypeReference" ) ;
1528
+ performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
1528
1529
tracing ?. pop ( ) ;
1529
1530
return result ;
1530
1531
}
@@ -2067,7 +2068,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2067
2068
function emitBuildInfo ( writeFileCallback ?: WriteFileCallback ) : EmitResult {
2068
2069
Debug . assert ( ! outFile ( options ) ) ;
2069
2070
tracing ?. push ( tracing . Phase . Emit , "emitBuildInfo" , { } , /*separateBeginAndEnd*/ true ) ;
2070
- ts . performance . mark ( "beforeEmit" ) ;
2071
+ performance . mark ( "beforeEmit" ) ;
2071
2072
const emitResult = emitFiles (
2072
2073
notImplementedResolver ,
2073
2074
getEmitHost ( writeFileCallback ) ,
@@ -2077,8 +2078,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2077
2078
/*onlyBuildInfo*/ true
2078
2079
) ;
2079
2080
2080
- ts . performance . mark ( "afterEmit" ) ;
2081
- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2081
+ performance . mark ( "afterEmit" ) ;
2082
+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2082
2083
tracing ?. pop ( ) ;
2083
2084
return emitResult ;
2084
2085
}
@@ -2163,7 +2164,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2163
2164
// checked is to not pass the file to getEmitResolver.
2164
2165
const emitResolver = getTypeChecker ( ) . getEmitResolver ( outFile ( options ) ? undefined : sourceFile , cancellationToken ) ;
2165
2166
2166
- ts . performance . mark ( "beforeEmit" ) ;
2167
+ performance . mark ( "beforeEmit" ) ;
2167
2168
2168
2169
const emitResult = emitFiles (
2169
2170
emitResolver ,
@@ -2175,8 +2176,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2175
2176
forceDtsEmit
2176
2177
) ;
2177
2178
2178
- ts . performance . mark ( "afterEmit" ) ;
2179
- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2179
+ performance . mark ( "afterEmit" ) ;
2180
+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2180
2181
return emitResult ;
2181
2182
}
2182
2183
0 commit comments