2019-07-14 20:37:26 +02:00

20 lines
444 B
JavaScript

import { BenchmarkType } from './Benchmark.js'
export class OpsPerTimeBenchmark extends BenchmarkType {
constructor(timeToRun) {
super()
this.timeToRun = timeToRun
}
async measure() {
let start = performance.now()
let iterations = 0
while (performance.now() - start < this.timeToRun) {
iterations++
await this.case.fn()
}
let stop = performance.now()
return (stop - start) / iterations
}
}