Merge pull request #453 from Microsoft/reportMemoryUsage
Include memory usage in -diagnostics report
This commit is contained in:
commit
2775fc2add
|
@ -14,7 +14,7 @@ interface System {
|
|||
createDirectory(directoryName: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
getMemoryUsage(): number;
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
|
||||
|
@ -128,9 +128,6 @@ var sys: System = (function () {
|
|||
getCurrentDirectory() {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
getMemoryUsage() {
|
||||
return 0;
|
||||
},
|
||||
exit(exitCode?: number): void {
|
||||
try {
|
||||
WScript.Quit(exitCode);
|
||||
|
@ -234,7 +231,9 @@ var sys: System = (function () {
|
|||
return (<any>process).cwd();
|
||||
},
|
||||
getMemoryUsage() {
|
||||
global.gc();
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
return process.memoryUsage().heapUsed;
|
||||
},
|
||||
exit(exitCode?: number): void {
|
||||
|
|
|
@ -337,12 +337,16 @@ module ts {
|
|||
|
||||
reportDiagnostics(errors);
|
||||
if (commandLine.options.diagnostics) {
|
||||
var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
reportCountStatistic("Files", program.getSourceFiles().length);
|
||||
reportCountStatistic("Lines", countLines(program));
|
||||
reportCountStatistic("Nodes", checker ? checker.getNodeCount() : 0);
|
||||
reportCountStatistic("Identifiers", checker ? checker.getIdentifierCount() : 0);
|
||||
reportCountStatistic("Symbols", checker ? checker.getSymbolCount() : 0);
|
||||
reportCountStatistic("Types", checker ? checker.getTypeCount() : 0);
|
||||
if (memoryUsed >= 0) {
|
||||
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
|
||||
}
|
||||
reportTimeStatistic("Parse time", bindStart - parseStart);
|
||||
reportTimeStatistic("Bind time", checkStart - bindStart);
|
||||
reportTimeStatistic("Check time", emitStart - checkStart);
|
||||
|
|
Loading…
Reference in a new issue