From 0be645943ae46254fc06fd30b3646f21dc35b30d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 14:51:04 -0800 Subject: [PATCH] Print times in a manner more consistent with the 1.3 compiler. This allows us to more accurately compare and constrast times between that compiler and the current one. --- src/compiler/program.ts | 3 +++ src/compiler/tsc.ts | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a8e5b0b3a74..88ab2825fd2 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3,6 +3,7 @@ module ts { /* @internal */ export var emitTime = 0; + /* @internal */ export var ioReadTime = 0; export function createCompilerHost(options: CompilerOptions): CompilerHost { var currentDirectory: string; @@ -19,7 +20,9 @@ module ts { function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile { try { + var start = new Date().getTime(); var text = sys.readFile(fileName, options.charset); + ioReadTime += new Date().getTime() - start; } catch (e) { if (onError) { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a3755650aed..57c2298d3d3 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -322,6 +322,7 @@ module ts { } function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) { + ts.ioReadTime = 0; ts.parseTime = 0; ts.bindTime = 0; ts.checkTime = 0; @@ -330,9 +331,12 @@ module ts { var start = new Date().getTime(); var program = createProgram(fileNames, compilerOptions, compilerHost); + var programTime = new Date().getTime() - start; + var exitStatus = compileProgram(); var end = new Date().getTime() - start; + var compileTime = end - programTime; if (compilerOptions.listFiles) { forEach(program.getSourceFiles(), file => { @@ -353,10 +357,19 @@ module ts { reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K"); } - reportTimeStatistic("Parse time", ts.parseTime); + // Individual component times. + // Note: we output 'programTime' as parseTime to match the tsc 1.3 behavior. tsc 1.3 + // measured parse time along with read IO as a single counter. We preserve that + // behavior so we can accurately compare times. For actual parse times (in isolation) + // is reported below. + reportTimeStatistic("Parse time", programTime); reportTimeStatistic("Bind time", ts.bindTime); reportTimeStatistic("Check time", ts.checkTime); reportTimeStatistic("Emit time", ts.emitTime); + + reportTimeStatistic("Parse time w/o IO", ts.parseTime); + reportTimeStatistic("IO read", ts.ioReadTime); + reportTimeStatistic("Compile time", compileTime); reportTimeStatistic("Total time", end); }