44/// <reference path="printer.ts" />
55
66namespace ts {
7- /* @internal */ export let programTime = 0 ;
8- /* @internal */ export let emitTime = 0 ;
9- /* @internal */ export let ioReadTime = 0 ;
10- /* @internal */ export let ioWriteTime = 0 ;
11-
127 /** The version of the TypeScript compiler release */
138
149 const emptyArray : any [ ] = [ ] ;
@@ -781,9 +776,10 @@ namespace ts {
781776 function getSourceFile ( fileName : string , languageVersion : ScriptTarget , onError ?: ( message : string ) => void ) : SourceFile {
782777 let text : string ;
783778 try {
784- const start = new Date ( ) . getTime ( ) ;
779+ Performance . mark ( "ioReadStart" ) ;
785780 text = sys . readFile ( fileName , options . charset ) ;
786- ioReadTime += new Date ( ) . getTime ( ) - start ;
781+ Performance . mark ( "ioReadEnd" ) ;
782+ Performance . measure ( "ioReadTime" , "ioReadStart" , "ioReadEnd" ) ;
787783 }
788784 catch ( e ) {
789785 if ( onError ) {
@@ -850,7 +846,7 @@ namespace ts {
850846
851847 function writeFile ( fileName : string , data : string , writeByteOrderMark : boolean , onError ?: ( message : string ) => void ) {
852848 try {
853- const start = new Date ( ) . getTime ( ) ;
849+ Performance . mark ( "ioWriteStart" ) ;
854850 ensureDirectoriesExist ( getDirectoryPath ( normalizePath ( fileName ) ) ) ;
855851
856852 if ( isWatchSet ( options ) && sys . createHash && sys . getModifiedTime ) {
@@ -860,7 +856,8 @@ namespace ts {
860856 sys . writeFile ( fileName , data , writeByteOrderMark ) ;
861857 }
862858
863- ioWriteTime += new Date ( ) . getTime ( ) - start ;
859+ Performance . mark ( "ioWriteEnd" ) ;
860+ Performance . measure ( "ioWriteTime" , "ioWriteStart" , "ioWriteEnd" ) ;
864861 }
865862 catch ( e ) {
866863 if ( onError ) {
@@ -962,7 +959,7 @@ namespace ts {
962959 let resolvedTypeReferenceDirectives : Map < ResolvedTypeReferenceDirective > = { } ;
963960 let fileProcessingDiagnostics = createDiagnosticCollection ( ) ;
964961
965- const start = new Date ( ) . getTime ( ) ;
962+ Performance . mark ( "programStart" ) ;
966963
967964 host = host || createCompilerHost ( options ) ;
968965
@@ -1055,7 +1052,8 @@ namespace ts {
10551052
10561053 verifyCompilerOptions ( ) ;
10571054
1058- programTime += new Date ( ) . getTime ( ) - start ;
1055+ Performance . mark ( "programEnd" ) ;
1056+ Performance . measure ( "programTime" , "programStart" , "programEnd" ) ;
10591057
10601058 return program ;
10611059
@@ -1288,7 +1286,7 @@ namespace ts {
12881286 // checked is to not pass the file to getEmitResolver.
12891287 const emitResolver = getDiagnosticsProducingTypeChecker ( ) . getEmitResolver ( ( options . outFile || options . out ) ? undefined : sourceFile ) ;
12901288
1291- const start = new Date ( ) . getTime ( ) ;
1289+ Performance . mark ( "emitStart" ) ;
12921290
12931291 // TODO(rbuckton): remove USE_TRANSFORMS condition when we switch to transforms permanently.
12941292 let useLegacyEmitter = options . useLegacyEmitter ;
@@ -1302,7 +1300,9 @@ namespace ts {
13021300 getEmitHost ( writeFileCallback ) ,
13031301 sourceFile ) ;
13041302
1305- emitTime += new Date ( ) . getTime ( ) - start ;
1303+ Performance . mark ( "emitEnd" ) ;
1304+ Performance . measure ( "emitTime" , "emitStart" , "emitEnd" ) ;
1305+
13061306 return emitResult ;
13071307 }
13081308
@@ -2076,7 +2076,7 @@ namespace ts {
20762076 }
20772077
20782078 // Cannot specify module gen that isn't amd or system with --out
2079- // Report this error if user specified --module moduleKind
2079+ // Report this error if user specified --module moduleKind
20802080 // or if there is external module in compilation which defaults to commonjs
20812081 const emitModuleKind = getEmitModuleKind ( options ) ;
20822082 if ( outFile && ( options . module || firstExternalModuleSourceFile ) && ! ( emitModuleKind === ModuleKind . AMD || emitModuleKind === ModuleKind . System ) ) {
0 commit comments