Skip to content

Commit 4ee70ed

Browse files
Merge pull request microsoft#2157 from Microsoft/timings
Print times in a manner more consistent with the 1.3 compiler.
2 parents 21fb559 + 0be6459 commit 4ee70ed

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/compiler/program.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
module ts {
55
/* @internal */ export var emitTime = 0;
6+
/* @internal */ export var ioReadTime = 0;
67

78
export function createCompilerHost(options: CompilerOptions): CompilerHost {
89
var currentDirectory: string;
@@ -19,7 +20,9 @@ module ts {
1920

2021
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
2122
try {
23+
var start = new Date().getTime();
2224
var text = sys.readFile(fileName, options.charset);
25+
ioReadTime += new Date().getTime() - start;
2326
}
2427
catch (e) {
2528
if (onError) {

src/compiler/tsc.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ module ts {
322322
}
323323

324324
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
325+
ts.ioReadTime = 0;
325326
ts.parseTime = 0;
326327
ts.bindTime = 0;
327328
ts.checkTime = 0;
@@ -330,9 +331,12 @@ module ts {
330331
var start = new Date().getTime();
331332

332333
var program = createProgram(fileNames, compilerOptions, compilerHost);
334+
var programTime = new Date().getTime() - start;
335+
333336
var exitStatus = compileProgram();
334337

335338
var end = new Date().getTime() - start;
339+
var compileTime = end - programTime;
336340

337341
if (compilerOptions.listFiles) {
338342
forEach(program.getSourceFiles(), file => {
@@ -353,10 +357,19 @@ module ts {
353357
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
354358
}
355359

356-
reportTimeStatistic("Parse time", ts.parseTime);
360+
// Individual component times.
361+
// Note: we output 'programTime' as parseTime to match the tsc 1.3 behavior. tsc 1.3
362+
// measured parse time along with read IO as a single counter. We preserve that
363+
// behavior so we can accurately compare times. For actual parse times (in isolation)
364+
// is reported below.
365+
reportTimeStatistic("Parse time", programTime);
357366
reportTimeStatistic("Bind time", ts.bindTime);
358367
reportTimeStatistic("Check time", ts.checkTime);
359368
reportTimeStatistic("Emit time", ts.emitTime);
369+
370+
reportTimeStatistic("Parse time w/o IO", ts.parseTime);
371+
reportTimeStatistic("IO read", ts.ioReadTime);
372+
reportTimeStatistic("Compile time", compileTime);
360373
reportTimeStatistic("Total time", end);
361374
}
362375

0 commit comments

Comments
 (0)