Perfsys no longer used

This commit is contained in:
jbondc 2015-02-19 15:20:34 -05:00
parent bf3f498688
commit 9ee494a1c9
4 changed files with 2 additions and 153 deletions

View file

@ -3,7 +3,6 @@
var fs = require("fs");
var os = require("os");
var path = require("path");
var child_process = require("child_process");
// Variables
var compilerDirectory = "src/compiler/";
@ -645,13 +644,6 @@ task("webhost", [webhostJsPath], function() {
jake.cpR(path.join(builtLocalDirectory, "lib.d.ts"), "tests/webhost/", {silent: true});
});
// Perf compiler
var perftscPath = "tests/perftsc.ts";
var perftscJsPath = "built/local/perftsc.js";
compileFile(perftscJsPath, [perftscPath], [tscFile, perftscPath, "tests/perfsys.ts"].concat(libraryTargets), [], /*useBuiltCompiler*/ true);
desc("Builds augmented version of the compiler for perf tests");
task("perftsc", [perftscJsPath]);
// Instrumented compiler
var loggedIOpath = harnessDirectory + 'loggedIO.ts';
var loggedIOJsPath = builtLocalDirectory + 'loggedIO.js';

View file

@ -152,10 +152,7 @@ module ts {
}
export function executeCommandLine(args: string[]): void {
return executeCommand(parseCommandLine(args));
}
export function executeCommand(commandLine: ParsedCommandLine): void {
var commandLine = parseCommandLine(args);
var configFileName: string; // Configuration file name (if any)
var configFileWatcher: FileWatcher; // Configuration file watcher
var cachedProgram: Program; // Program cached from last compilation
@ -261,7 +258,7 @@ module ts {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
}
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) {
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) {
// Return existing SourceFile object if one is available
if (cachedProgram) {
var sourceFile = cachedProgram.getSourceFile(fileName);

View file

@ -1,99 +0,0 @@
/// <reference path="..\src\compiler\sys.ts"/>
/// <reference path="..\src\compiler\types.ts"/>
module perftest {
interface IOLog {
resolvePath: ts.Map<string>;
fileNames: string[];
}
export interface IO {
getOut(): string;
}
export var readFile = ts.sys.readFile;
var writeFile = ts.sys.writeFile;
export var write = ts.sys.write;
var resolvePath = ts.sys.resolvePath;
export var getExecutingFilePath = ts.sys.getExecutingFilePath;
export var getCurrentDirectory = ts.sys.getCurrentDirectory;
var exit = ts.sys.exit;
// augment sys so first ts.executeCommandLine call will be finish silently
ts.sys.write = (s: string) => { };
ts.sys.exit = (code: number) => { };
var resolvePathLog: ts.Map<string> = {};
export function interceptIO() {
ts.sys.resolvePath = (s) => {
var result = resolvePath(s);
resolvePathLog[s] = result;
return result;
};
}
export function writeIOLog(fileNames: string[], dstPath: string) {
var log: IOLog = {
fileNames: fileNames,
resolvePath: resolvePathLog
};
writeFile(dstPath, JSON.stringify(log));
}
export function prepare(cmd: ts.ParsedCommandLine): IO {
var content = readFile(cmd.fileNames[0]);
if (content === undefined) {
throw new Error('Invalid file: ' + cmd.fileNames[0])
}
try {
var log = <IOLog>JSON.parse(content);
}
catch (err) {
write("Invalid IO log file, expecting JSON")
}
cmd.fileNames = []
var files: ts.Map<string> = {};
log.fileNames.forEach(f => {
files[f] = readFile(f);
cmd.fileNames.push(f)
})
ts.sys.createDirectory = (s: string) => { };
ts.sys.directoryExists = (s: string) => true;
ts.sys.fileExists = (s: string) => true;
var currentDirectory = ts.sys.getCurrentDirectory();
ts.sys.getCurrentDirectory = () => currentDirectory;
var executingFilePath = ts.sys.getExecutingFilePath();
ts.sys.getExecutingFilePath = () => executingFilePath;
ts.sys.readFile = (s: string) => {
return files[s];
}
ts.sys.resolvePath = (s: string) => {
var path = log.resolvePath[s];
if (!path) {
throw new Error("Unexpected path '" + s + "'");
}
return path
}
ts.sys.writeFile = (path: string, data: string) => { };
var out: string = "";
ts.sys.write = (s: string) => {
out += s;
};
return {
getOut: () => out,
};
}
}

View file

@ -1,41 +0,0 @@
/// <reference path="perfsys.ts"/>
/// <reference path="..\src\compiler\tsc.ts"/>
// resolve all files used in this compilation
ts.optionDeclarations.push({
name: "logio",
type: "string",
isFilePath: true
})
var commandLine = ts.parseCommandLine(ts.sys.args);
commandLine.options.diagnostics = true
var logIoPath = commandLine.options['logio'];
if (logIoPath) {
perftest.interceptIO();
var compilerHost: ts.CompilerHost = {
getSourceFile: (s, v) => {
var content = perftest.readFile(s);
return content !== undefined ? ts.createSourceFile(s, content, v) : undefined;
},
getDefaultLibFileName: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"),
writeFile: (f: string, content: string) => { throw new Error("Unexpected operation: writeFile"); },
getCurrentDirectory: () => perftest.getCurrentDirectory(),
getCanonicalFileName: (f: string) => ts.sys.useCaseSensitiveFileNames ? f : f.toLowerCase(),
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
getNewLine: () => ts.sys.newLine
};
var program = ts.createProgram(commandLine.fileNames, commandLine.options, compilerHost);
var fileNames = program.getSourceFiles().map(f => f.fileName);
perftest.writeIOLog(fileNames, "" + logIoPath);
}
else {
var io = perftest.prepare(commandLine);
ts.executeCommand(commandLine);
perftest.write(io.getOut());
}