29 lines
765 B
JavaScript
29 lines
765 B
JavaScript
import { IterationsBenchmark } from './IterationBenchmark'
|
|
import { OpsPerTimeBenchmark } from './OpsPerTimeBenchmark'
|
|
import { BenchmarkJSBenchmark } from './BenchmarkJSBenchmark'
|
|
|
|
export const benchmarkTypes = {
|
|
benchmarkJS: BenchmarkJSBenchmark,
|
|
iteration: IterationsBenchmark,
|
|
opsPerTime: OpsPerTimeBenchmark
|
|
}
|
|
|
|
export const benchmarkTypeSelector = ({
|
|
benchMethod,
|
|
iterations,
|
|
timeToRun
|
|
}) => {
|
|
switch (benchMethod) {
|
|
case 'benchmarkJS':
|
|
return new BenchmarkJSBenchmark()
|
|
case 'iteration':
|
|
return new IterationsBenchmark(iterations)
|
|
|
|
case 'opsPerTime':
|
|
return new OpsPerTimeBenchmark(timeToRun)
|
|
default:
|
|
console.warn('benchmark type "' + name + '" not known')
|
|
return new IterationsBenchmark(10)
|
|
}
|
|
}
|