Merge pull request #2354 from Microsoft/cleanupDiagnostics

Clean up diagnostics display
This commit is contained in:
Anders Hejlsberg
2015-03-17 09:28:49 -07:00
3 changed files with 44 additions and 55 deletions
-8
View File
@@ -5310,14 +5310,6 @@ module ts {
}
}
function getFirstExportAssignment(sourceFile: SourceFile) {
return forEach(sourceFile.statements, node => {
if (node.kind === SyntaxKind.ExportAssignment) {
return <ExportAssignment>node;
}
});
}
function sortAMDModules(amdModules: {name: string; path: string}[]) {
// AMD modules with declared variable names go first
return amdModules.sort((moduleA, moduleB) => {
+29 -23
View File
@@ -2,8 +2,10 @@
/// <reference path="emitter.ts" />
module ts {
/* @internal */ export let programTime = 0;
/* @internal */ export let emitTime = 0;
/* @internal */ export let ioReadTime = 0;
/* @internal */ export let ioWriteTime = 0;
/** The version of the TypeScript compiler release */
export let version = "1.5.0.0";
@@ -36,33 +38,34 @@ module ts {
}
text = "";
}
return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined;
}
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
}
function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
let parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
}
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
}
function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
let parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
}
try {
var start = new Date().getTime();
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
sys.writeFile(fileName, data, writeByteOrderMark);
ioWriteTime += new Date().getTime() - start;
}
catch (e) {
if (onError) {
@@ -120,16 +123,19 @@ module ts {
let diagnostics = createDiagnosticCollection();
let seenNoDefaultLib = options.noLib;
let commonSourceDirectory: string;
host = host || createCompilerHost(options);
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
let start = new Date().getTime();
host = host || createCompilerHost(options);
forEach(rootNames, name => processRootFile(name, false));
if (!seenNoDefaultLib) {
processRootFile(host.getDefaultLibFileName(options), true);
}
verifyCompilerOptions();
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
programTime += new Date().getTime() - start;
program = {
getSourceFile: getSourceFile,
+15 -24
View File
@@ -320,22 +320,16 @@ module ts {
}
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
ts.ioReadTime = 0;
ts.parseTime = 0;
ts.bindTime = 0;
ts.checkTime = 0;
ts.emitTime = 0;
var start = new Date().getTime();
ioReadTime = 0;
ioWriteTime = 0;
programTime = 0;
bindTime = 0;
checkTime = 0;
emitTime = 0;
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 => {
sys.write(file.fileName + sys.newLine);
@@ -356,19 +350,16 @@ module ts {
}
// 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.
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
// I/O read time and processing time for triple-slash references and module imports, and the reported
// emit time includes I/O write time. We preserve this behavior so we can accurately compare times.
reportTimeStatistic("I/O read", ioReadTime);
reportTimeStatistic("I/O write", ioWriteTime);
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);
reportTimeStatistic("Bind time", bindTime);
reportTimeStatistic("Check time", checkTime);
reportTimeStatistic("Emit time", emitTime);
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
}
return { program, exitStatus };