From 85d345dd1087510e9299ece40e4768f55e8787c4 Mon Sep 17 00:00:00 2001 From: Alfred Melch Date: Tue, 6 Aug 2019 11:15:12 +0200 Subject: [PATCH] initialize suite on form change --- benchmarking/src/benchmarks/BenchmarkSuite.js | 2 ++ benchmarking/src/components/runner.js | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/benchmarking/src/benchmarks/BenchmarkSuite.js b/benchmarking/src/benchmarks/BenchmarkSuite.js index db1fdd0..f0487d7 100644 --- a/benchmarking/src/benchmarks/BenchmarkSuite.js +++ b/benchmarking/src/benchmarks/BenchmarkSuite.js @@ -13,11 +13,13 @@ export class BenchmarkSuite { setBenchmarkType(benchmarktype) { this.benchmarktype = benchmarktype + this.onChange() } setCases(cases) { this.cases = new CasesIterator(cases) this.stats = this.cases.getInitialStats() + this.onChange() } addStat(name, val) { diff --git a/benchmarking/src/components/runner.js b/benchmarking/src/components/runner.js index 86cc909..3a96850 100644 --- a/benchmarking/src/components/runner.js +++ b/benchmarking/src/components/runner.js @@ -37,13 +37,16 @@ export class BenchmarkRunner extends Component { if (prevState !== this.state) { this.props.onStatsChange(this.suite.stats) } + if (prevProps.formState !== this.props.formState) { + this.initializeSuite() + this.suite.stop() + } } initializeSuite() { let data = dataSelector[this.props.formState.dataset] this.suite.setBenchmarkType(benchmarkTypeSelector(this.props.formState)) this.suite.setCases(generateCases(data, this.props.formState)) - this.suite.start() } stateIsOneOf(states) { @@ -83,7 +86,14 @@ export class BenchmarkRunner extends Component { {this.startButtonShown() && ( - + )} {this.resumeButtonShown() && (