export class BenchmarkType { /** * Superclass for benchmarking a Case * @param {object} parameters - Parameters for use in fn * @param {object} functions - setup, fn and tearDown methods */ constructor() { this.stats = {} } setCase(benchmarkCase) { this.case = benchmarkCase } /** Returns the mean time in milliseconds */ async run() { let mean if (typeof this.case === 'undefined') { throw Error('no Benchmarking case set') } await this.case.setup() mean = await this.measure() await this.case.tearDown() return mean } /** Implementation of the benchmarking procedure */ async measure() { throw new Error('Method "measure" not implemented!') } }