Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
15 changes: 14 additions & 1 deletion src/compiler/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 => {
Expand All @@ -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);
}

Expand Down