@@ -59,6 +59,7 @@ import {
59
59
VariableStatement , walkUpParenthesizedExpressions , WriteFileCallback , WriteFileCallbackData ,
60
60
writeFileEnsuringDirectories , zipToModeAwareCache ,
61
61
} from "./_namespaces/ts" ;
62
+ import * as performance from "./_namespaces/ts.performance" ;
62
63
63
64
export function findConfigFile ( searchPath : string , fileExists : ( fileName : string ) => boolean , configName = "tsconfig.json" ) : string | undefined {
64
65
return forEachAncestorDirectory ( searchPath , ancestor => {
@@ -130,10 +131,10 @@ export function createCompilerHostWorker(options: CompilerOptions, setParentNode
130
131
function getSourceFile ( fileName : string , languageVersionOrOptions : ScriptTarget | CreateSourceFileOptions , onError ?: ( message : string ) => void ) : SourceFile | undefined {
131
132
let text : string | undefined ;
132
133
try {
133
- ts . performance . mark ( "beforeIORead" ) ;
134
+ performance . mark ( "beforeIORead" ) ;
134
135
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" ) ;
137
138
}
138
139
catch ( e ) {
139
140
if ( onError ) {
@@ -157,7 +158,7 @@ export function createCompilerHostWorker(options: CompilerOptions, setParentNode
157
158
158
159
function writeFile ( fileName : string , data : string , writeByteOrderMark : boolean , onError ?: ( message : string ) => void ) {
159
160
try {
160
- ts . performance . mark ( "beforeIOWrite" ) ;
161
+ performance . mark ( "beforeIOWrite" ) ;
161
162
162
163
// NOTE: If patchWriteFileEnsuringDirectory has been called,
163
164
// the system.writeFile will do its own directory creation and
@@ -170,8 +171,8 @@ export function createCompilerHostWorker(options: CompilerOptions, setParentNode
170
171
path => ( compilerHost . createDirectory || system . createDirectory ) ( path ) ,
171
172
path => directoryExists ( path ) ) ;
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 ) {
@@ -1122,7 +1123,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1122
1123
const sourceFilesFoundSearchingNodeModules = new Map < string , boolean > ( ) ;
1123
1124
1124
1125
tracing ?. push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
1125
- ts . performance . mark ( "beforeProgram" ) ;
1126
+ performance . mark ( "beforeProgram" ) ;
1126
1127
1127
1128
const host = createProgramOptions . host || createCompilerHost ( options ) ;
1128
1129
const configParsingHost = parseConfigHostFromCompilerHostLike ( host ) ;
@@ -1428,8 +1429,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1428
1429
} ) ;
1429
1430
1430
1431
verifyCompilerOptions ( ) ;
1431
- ts . performance . mark ( "afterProgram" ) ;
1432
- ts . performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1432
+ performance . mark ( "afterProgram" ) ;
1433
+ performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1433
1434
tracing ?. pop ( ) ;
1434
1435
1435
1436
return program ;
@@ -1469,10 +1470,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1469
1470
const containingFileName = getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) ;
1470
1471
const redirectedReference = getRedirectReferenceForResolution ( containingFile ) ;
1471
1472
tracing ?. push ( tracing . Phase . Program , "resolveModuleNamesWorker" , { containingFileName } ) ;
1472
- ts . performance . mark ( "beforeResolveModule" ) ;
1473
+ performance . mark ( "beforeResolveModule" ) ;
1473
1474
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" ) ;
1476
1477
tracing ?. pop ( ) ;
1477
1478
pullDiagnosticsFromCache ( moduleNames , containingFile ) ;
1478
1479
return result ;
@@ -1484,10 +1485,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1484
1485
const redirectedReference = ! isString ( containingFile ) ? getRedirectReferenceForResolution ( containingFile ) : undefined ;
1485
1486
const containingFileMode = ! isString ( containingFile ) ? containingFile . impliedNodeFormat : undefined ;
1486
1487
tracing ?. push ( tracing . Phase . Program , "resolveTypeReferenceDirectiveNamesWorker" , { containingFileName } ) ;
1487
- ts . performance . mark ( "beforeResolveTypeReference" ) ;
1488
+ performance . mark ( "beforeResolveTypeReference" ) ;
1488
1489
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" ) ;
1491
1492
tracing ?. pop ( ) ;
1492
1493
return result ;
1493
1494
}
@@ -2032,7 +2033,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2032
2033
function emitBuildInfo ( writeFileCallback ?: WriteFileCallback ) : EmitResult {
2033
2034
Debug . assert ( ! outFile ( options ) ) ;
2034
2035
tracing ?. push ( tracing . Phase . Emit , "emitBuildInfo" , { } , /*separateBeginAndEnd*/ true ) ;
2035
- ts . performance . mark ( "beforeEmit" ) ;
2036
+ performance . mark ( "beforeEmit" ) ;
2036
2037
const emitResult = emitFiles (
2037
2038
notImplementedResolver ,
2038
2039
getEmitHost ( writeFileCallback ) ,
@@ -2042,8 +2043,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2042
2043
/*onlyBuildInfo*/ true
2043
2044
) ;
2044
2045
2045
- ts . performance . mark ( "afterEmit" ) ;
2046
- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2046
+ performance . mark ( "afterEmit" ) ;
2047
+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2047
2048
tracing ?. pop ( ) ;
2048
2049
return emitResult ;
2049
2050
}
@@ -2127,7 +2128,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2127
2128
// checked is to not pass the file to getEmitResolver.
2128
2129
const emitResolver = getTypeChecker ( ) . getEmitResolver ( outFile ( options ) ? undefined : sourceFile , cancellationToken ) ;
2129
2130
2130
- ts . performance . mark ( "beforeEmit" ) ;
2131
+ performance . mark ( "beforeEmit" ) ;
2131
2132
2132
2133
const emitResult = emitFiles (
2133
2134
emitResolver ,
@@ -2139,8 +2140,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2139
2140
forceDtsEmit
2140
2141
) ;
2141
2142
2142
- ts . performance . mark ( "afterEmit" ) ;
2143
- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2143
+ performance . mark ( "afterEmit" ) ;
2144
+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2144
2145
return emitResult ;
2145
2146
}
2146
2147
0 commit comments