@@ -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 ) {
@@ -1118,7 +1119,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1118
1119
const sourceFilesFoundSearchingNodeModules = new Map < string , boolean > ( ) ;
1119
1120
1120
1121
tracing ?. push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
1121
- ts . performance . mark ( "beforeProgram" ) ;
1122
+ performance . mark ( "beforeProgram" ) ;
1122
1123
1123
1124
const host = createProgramOptions . host || createCompilerHost ( options ) ;
1124
1125
const configParsingHost = parseConfigHostFromCompilerHostLike ( host ) ;
@@ -1424,8 +1425,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1424
1425
} ) ;
1425
1426
1426
1427
verifyCompilerOptions ( ) ;
1427
- ts . performance . mark ( "afterProgram" ) ;
1428
- ts . performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1428
+ performance . mark ( "afterProgram" ) ;
1429
+ performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1429
1430
tracing ?. pop ( ) ;
1430
1431
1431
1432
return program ;
@@ -1465,10 +1466,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1465
1466
const containingFileName = getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) ;
1466
1467
const redirectedReference = getRedirectReferenceForResolution ( containingFile ) ;
1467
1468
tracing ?. push ( tracing . Phase . Program , "resolveModuleNamesWorker" , { containingFileName } ) ;
1468
- ts . performance . mark ( "beforeResolveModule" ) ;
1469
+ performance . mark ( "beforeResolveModule" ) ;
1469
1470
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" ) ;
1472
1473
tracing ?. pop ( ) ;
1473
1474
pullDiagnosticsFromCache ( moduleNames , containingFile ) ;
1474
1475
return result ;
@@ -1480,10 +1481,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1480
1481
const redirectedReference = ! isString ( containingFile ) ? getRedirectReferenceForResolution ( containingFile ) : undefined ;
1481
1482
const containingFileMode = ! isString ( containingFile ) ? containingFile . impliedNodeFormat : undefined ;
1482
1483
tracing ?. push ( tracing . Phase . Program , "resolveTypeReferenceDirectiveNamesWorker" , { containingFileName } ) ;
1483
- ts . performance . mark ( "beforeResolveTypeReference" ) ;
1484
+ performance . mark ( "beforeResolveTypeReference" ) ;
1484
1485
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" ) ;
1487
1488
tracing ?. pop ( ) ;
1488
1489
return result ;
1489
1490
}
@@ -2028,7 +2029,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2028
2029
function emitBuildInfo ( writeFileCallback ?: WriteFileCallback ) : EmitResult {
2029
2030
Debug . assert ( ! outFile ( options ) ) ;
2030
2031
tracing ?. push ( tracing . Phase . Emit , "emitBuildInfo" , { } , /*separateBeginAndEnd*/ true ) ;
2031
- ts . performance . mark ( "beforeEmit" ) ;
2032
+ performance . mark ( "beforeEmit" ) ;
2032
2033
const emitResult = emitFiles (
2033
2034
notImplementedResolver ,
2034
2035
getEmitHost ( writeFileCallback ) ,
@@ -2038,8 +2039,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2038
2039
/*onlyBuildInfo*/ true
2039
2040
) ;
2040
2041
2041
- ts . performance . mark ( "afterEmit" ) ;
2042
- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2042
+ performance . mark ( "afterEmit" ) ;
2043
+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2043
2044
tracing ?. pop ( ) ;
2044
2045
return emitResult ;
2045
2046
}
@@ -2123,7 +2124,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2123
2124
// checked is to not pass the file to getEmitResolver.
2124
2125
const emitResolver = getTypeChecker ( ) . getEmitResolver ( outFile ( options ) ? undefined : sourceFile , cancellationToken ) ;
2125
2126
2126
- ts . performance . mark ( "beforeEmit" ) ;
2127
+ performance . mark ( "beforeEmit" ) ;
2127
2128
2128
2129
const emitResult = emitFiles (
2129
2130
emitResolver ,
@@ -2135,8 +2136,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2135
2136
forceDtsEmit
2136
2137
) ;
2137
2138
2138
- ts . performance . mark ( "afterEmit" ) ;
2139
- ts . performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2139
+ performance . mark ( "afterEmit" ) ;
2140
+ performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
2140
2141
return emitResult ;
2141
2142
}
2142
2143
0 commit comments