Skip to content

Commit 4d62b48

Browse files
committed
Include memory usage in -diagnostics report
1 parent 2a106bf commit 4d62b48

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/compiler/sys.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ var sys: System = (function () {
234234
return (<any>process).cwd();
235235
},
236236
getMemoryUsage() {
237-
global.gc();
237+
if (global.gc) {
238+
global.gc();
239+
}
238240
return process.memoryUsage().heapUsed;
239241
},
240242
exit(exitCode?: number): void {

src/compiler/tsc.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,16 @@ module ts {
337337

338338
reportDiagnostics(errors);
339339
if (commandLine.options.diagnostics) {
340+
var memoryUsed = sys.getMemoryUsage();
340341
reportCountStatistic("Files", program.getSourceFiles().length);
341342
reportCountStatistic("Lines", countLines(program));
342343
reportCountStatistic("Nodes", checker ? checker.getNodeCount() : 0);
343344
reportCountStatistic("Identifiers", checker ? checker.getIdentifierCount() : 0);
344345
reportCountStatistic("Symbols", checker ? checker.getSymbolCount() : 0);
345346
reportCountStatistic("Types", checker ? checker.getTypeCount() : 0);
347+
if (memoryUsed) {
348+
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
349+
}
346350
reportTimeStatistic("Parse time", bindStart - parseStart);
347351
reportTimeStatistic("Bind time", checkStart - bindStart);
348352
reportTimeStatistic("Check time", emitStart - checkStart);

0 commit comments

Comments
 (0)