diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 15d1917b5cd..c717cb19472 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -139,6 +139,7 @@ module Harness { deleteFile(filename: string): void; listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; + getMemoryUsage? (): number; } module IOImpl { @@ -275,6 +276,13 @@ module Harness { return filesInFolder(path); } + + export var getMemoryUsage: typeof IO.getMemoryUsage = () => { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + } } export module Network { diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 882620a69da..9ef344fe6a4 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -47,19 +47,9 @@ module RWC { export function runRWCTest(jsonPath: string) { describe("Testing a RWC project: " + jsonPath, () => { - var harnessCompiler = Harness.Compiler.getCompiler(); - var opts: ts.ParsedCommandLine; - - var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); - var errors = ''; - after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. - harnessCompiler = undefined; - opts = undefined; - ioLog = undefined; - errors = undefined; inputFiles = undefined; otherFiles = undefined; compilerResult = undefined; @@ -67,21 +57,30 @@ module RWC { baselineOpts = undefined; baseName = undefined; declFileCompilationResult = undefined; + //if (Harness.IO.getMemoryUsage) { + // console.log(Harness.IO.getMemoryUsage()); + //} }); - - it('has parsable options', () => { - runWithIOLog(ioLog, () => { - opts = ts.parseCommandLine(ioLog.arguments); - assert.equal(opts.errors.length, 0); - }); - }); + //var startTime: number; + //it('getTimeStart', () => { + // startTime = new Date().getTime(); + //}); var inputFiles: { unitName: string; content: string; }[] = []; var otherFiles: { unitName: string; content: string; }[] = []; var compilerResult: Harness.Compiler.CompilerResult; var compilerOptions: ts.CompilerOptions; it('can compile', () => { + var harnessCompiler = Harness.Compiler.getCompiler(); + var opts: ts.ParsedCommandLine; + + var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); + runWithIOLog(ioLog, () => { + opts = ts.parseCommandLine(ioLog.arguments); + assert.equal(opts.errors.length, 0); + }); + runWithIOLog(ioLog, () => { harnessCompiler.reset(); @@ -139,7 +138,7 @@ module RWC { declResult: Harness.Compiler.CompilerResult; }; it('Correct compiler generated.d.ts', () => { - declFileCompilationResult = harnessCompiler.compileDeclarationFiles(inputFiles, otherFiles, compilerResult, /*settingscallback*/ undefined, compilerOptions); + declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, /*settingscallback*/ undefined, compilerOptions); }); @@ -200,6 +199,10 @@ module RWC { } }); + //it('EndTIme', () => { + // console.log("Parse time:" + baseName+ " (" + (new Date().getTime() - startTime) + ")"); + //}); + // TODO: Type baselines (need to refactor out from compilerRunner) }); }