Skip to content

Commit ef533da

Browse files
committed
Make a RunData class
This class encapsulates the tuple of options, version and run data. ScoreCalculator can then store this in `runData`, replacing the separate storage of `options`, `version` and the confusingly named `_iterationsSamplers`.
1 parent c2f7f50 commit ef533da

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

MotionMark/resources/debug-runner/debug-runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ class DebugBenchmarkController extends BenchmarkController {
599599

600600
this.migrateImportedData(run);
601601
this.ensureRunnerClient([ ], { });
602-
this.runnerClient.scoreCalculator = new ScoreCalculator(run.version, run.options, run.data);
602+
this.runnerClient.scoreCalculator = new ScoreCalculator(new RunData(run.version, run.options, run.data));
603603
this.showResults();
604604
};
605605

MotionMark/resources/runner/motionmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class BenchmarkRunnerClient {
4545

4646
willStartFirstIteration()
4747
{
48-
this.scoreCalculator = new ScoreCalculator(Strings.version, this.options);
48+
this.scoreCalculator = new ScoreCalculator(new RunData(Strings.version, this.options));
4949
}
5050

5151
didRunSuites(suitesSamplers)

MotionMark/resources/runner/results.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,29 @@
2323
* THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
2525

26+
class RunData {
27+
constructor(version, options, runs = [])
28+
{
29+
this.version = version;
30+
this.options = options;
31+
this.runs = runs;
32+
}
33+
}
34+
2635
class ScoreCalculator {
27-
constructor(version, options, testData)
36+
constructor(runData)
2837
{
29-
this._iterationsSamplers = [];
30-
this._options = options;
38+
this._runData = runData;
3139
this._results = null;
32-
this._version = version;
33-
this._targetFrameRate = options["frame-rate"];
34-
this._systemFrameRate = options["system-frame-rate"];
40+
this._targetFrameRate = runData.options["frame-rate"];
41+
this._systemFrameRate = runData.options["system-frame-rate"];
3542

3643
const defaultBootstrapIterations = 2500;
37-
if (!Object.hasOwn(this._options, Strings.json.bootstrapIterations))
38-
this._options[Strings.json.bootstrapIterations] = defaultBootstrapIterations;
44+
if (!Object.hasOwn(this._runData.options, Strings.json.bootstrapIterations))
45+
this._runData.options[Strings.json.bootstrapIterations] = defaultBootstrapIterations;
3946

40-
if (testData) {
41-
this._iterationsSamplers = testData;
47+
if (this._runData.runs.length > 0)
4248
this._processData();
43-
}
4449
}
4550

4651
get targetFrameRate()
@@ -50,7 +55,7 @@ class ScoreCalculator {
5055

5156
push(suitesSamplers)
5257
{
53-
this._iterationsSamplers.push(suitesSamplers);
58+
this._runData.runs.push(suitesSamplers);
5459
}
5560

5661
_processData()
@@ -59,7 +64,7 @@ class ScoreCalculator {
5964
this._results[Strings.json.results.iterations] = [];
6065

6166
var iterationsScores = [];
62-
this._iterationsSamplers.forEach(function(iteration, index) {
67+
this._runData.runs.forEach(function(iteration, index) {
6368
var testsScores = [];
6469
var testsLowerBoundScores = [];
6570
var testsUpperBoundScores = [];
@@ -95,7 +100,7 @@ class ScoreCalculator {
95100
iterationsScores.push(result[Strings.json.score]);
96101
}, this);
97102

98-
this._results[Strings.json.version] = this._version;
103+
this._results[Strings.json.version] = this._runData.version;
99104
this._results[Strings.json.fps] = this._targetFrameRate;
100105
this._results[Strings.json.score] = Statistics.sampleMean(iterationsScores.length, iterationsScores.reduce(function(a, b) { return a + b; }));
101106
this._results[Strings.json.scoreLowerBound] = this._results[Strings.json.results.iterations][0][Strings.json.scoreLowerBound];
@@ -149,7 +154,7 @@ class ScoreCalculator {
149154
samples[seriesName] = new SampleData(series.fieldMap, series.data);
150155
});
151156

152-
var isRampController = this._options["controller"] == "ramp";
157+
var isRampController = this._runData.options[Strings.json.controller] == "ramp";
153158
var predominantProfile = "";
154159
if (isRampController) {
155160
var profiles = {};
@@ -198,7 +203,7 @@ class ScoreCalculator {
198203
experimentResult[Strings.json.measurements.stdev] = timeComplexity.standardDeviation();
199204
experimentResult[Strings.json.measurements.percent] = timeComplexity.percentage();
200205

201-
const bootstrapIterations = this._options[Strings.json.bootstrapIterations];
206+
const bootstrapIterations = this._runData.options[Strings.json.bootstrapIterations];
202207
var bootstrapResult = Regression.bootstrap(regressionResult.samples.data, bootstrapIterations, function(resampleData) {
203208
var complexityIndex = regressionResult.samples.fieldMap[Strings.json.complexity];
204209
resampleData.sort(function(a, b) {
@@ -265,7 +270,7 @@ class ScoreCalculator {
265270

266271
get data()
267272
{
268-
return this._iterationsSamplers;
273+
return this._runData.runs;
269274
}
270275

271276
get results()
@@ -278,12 +283,12 @@ class ScoreCalculator {
278283

279284
get options()
280285
{
281-
return this._options;
286+
return this._runData.options;
282287
}
283288

284289
get version()
285290
{
286-
return this._version;
291+
return this._runData.version;
287292
}
288293

289294
_getResultsProperty(property)

MotionMark/unit-tests/tests/test-data-import.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ describe('Data Import', function() {
4646
// Make the results analysis faster.
4747
this.json.options[Strings.json.bootstrapIterations] = 10;
4848

49-
const calculator = new ScoreCalculator(this.json.version, this.json.options, this.json.data);
49+
const runData = new RunData(this.json.version, this.json.options, this.json.data);
50+
const calculator = new ScoreCalculator(runData);
5051
this.results = calculator.results;
5152
expect(this.results instanceof Array).to.be(true);
5253
});

0 commit comments

Comments
 (0)