@specs-feup/lara
Version:
A js port of the popular framework for building source-to-source compilers
95 lines • 3.85 kB
TypeScript
import { LaraJoinPoint } from "../../LaraJoinPoint.js";
import { JavaClasses } from "../util/JavaTypes.js";
import ProcessExecutor from "../util/ProcessExecutor.js";
import BenchmarkCompilationEngine from "./BenchmarkCompilationEngine.js";
/**
* Represents a set of BenchmarkInstances.
*
* @param name - The name of this benchmark instance.
*/
export default abstract class BenchmarkInstance {
private name;
private hasLoaded;
private hasCompiled;
private currentExecutor;
private currentExecutable;
private compilationEngine;
private _isCachedAst;
static CACHE_ENABLE: boolean;
constructor(name: string);
protected abstract compilationEngineProvider(name: string): BenchmarkCompilationEngine;
setCompilationEngine<T extends BenchmarkCompilationEngine>(compilationEngineProvider: new (name: string) => T): void;
/**
* @returns The name of this BenchmarkInstance.
*/
getName(): string;
/**
* @param enable - If true, enables caching of parsed files. By default, caching is enabled.
*/
static setCache(enable: boolean): void;
/**
* @returns Temporary folder for caching ASTs.
*/
protected static getCacheFolder(): JavaClasses.File;
/**
* Clears compilation cache of all BenchmarkInstances.
*/
static purgeCache(): void;
isCachedAst(): boolean;
/**
* @returns The File representing the cached program of this BenchmarkInstance. The file might not exist.
*/
private getCachedFile;
/**
* @returns The base folder for all benchmark instances. Currently is a folder 'laraBenchmarks' inside the working directory.
*/
getBaseFolder(): JavaClasses.File;
/**
* @returns An available BenchmarkCompilationEngine that can be used to run compiled the program (implementations may vary). If used, can be used to configure the compilation.
*/
getCompilationEngine(): BenchmarkCompilationEngine;
/**
* @returns The executor that will be used to run the compiled program, can be used to configure the execution.
*/
getExecutor(): ProcessExecutor;
/**
* Saves the current AST and loads this benchmark into the AST.
*/
load(): void;
/**
* Restores the AST previous to load().
*/
close(): void;
/**
* Compiles the current version of the benchmark that is in the AST. Requires calling .load() first.
*/
compile(): JavaClasses.File | undefined;
/**
* Executes the current version of the benchmark. Requires calling .compile() first.
*
* @returns the ProcessExecutor used to execute this instance
*/
execute(): ProcessExecutor;
protected executePrivate(): void;
setExecutable(executable: JavaClasses.File): void;
/**
* Test the current instance.
*
* @param worker - Function with no parameters that will be called after loading the benchmark code as AST.
* @param executeCode - If true, executes the code after worker is applied.
* @param outputProcessor - If execution is enabled, will be called after execution with the corresponding ProcessExecutor.
*
* @returns True, if finished without problems
*/
test(worker?: (instance: BenchmarkInstance) => boolean, executeCode?: boolean, outputProcessor?: (executor: ProcessExecutor) => void): boolean;
/*** FUNCTIONS TO IMPLEMENT ***/
protected abstract loadPrivate(): void;
protected abstract closePrivate(): void;
protected abstract compilePrivate(): JavaClasses.File | undefined;
protected abstract loadCached(astFile: JavaClasses.File): void;
/**
* @returns Point in the code representing the execution of the benchmark kernel, around which metrics should be measured.
*/
abstract getKernel(): LaraJoinPoint;
}
//# sourceMappingURL=BenchmarkInstance.d.ts.map