Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up the classes that handle run results, and correctly import JSON files with multiple runs #77

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MotionMark/developer.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<script src="resources/runner/tests.js" charset="utf-8"></script>
<script src="resources/debug-runner/tests.js" charset="utf-8"></script>
<script src="resources/runner/motionmark.js"></script>
<script src="resources/runner/results.js"></script>
<script src="resources/debug-runner/debug-runner.js" charset="utf-8"></script>

<script src="resources/runner/benchmark-runner.js"></script>
Expand Down
1 change: 1 addition & 0 deletions MotionMark/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

<script src="resources/runner/tests.js" charset="utf-8" defer></script>
<script src="resources/runner/motionmark.js" defer></script>
<script src="resources/runner/results.js" defer></script>

<script src="resources/runner/benchmark-runner.js" defer></script>

Expand Down
63 changes: 25 additions & 38 deletions MotionMark/resources/debug-runner/debug-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ class DebugSectionsManager extends SectionsManager {
document.querySelector("#" + sectionIdentifier + " h1").textContent = title;
}

populateTable(tableIdentifier, headers, dashboard)
populateTable(tableIdentifier, headers, scoreCalculator)
{
var table = new DeveloperResultsTable(document.getElementById(tableIdentifier), headers);
table.showIterations(dashboard);
table.showIterations(scoreCalculator);
}
}

Expand Down Expand Up @@ -534,7 +534,7 @@ class DebugBenchmarkController extends BenchmarkController {
this.updateUIStrings();
this.graphController = new GraphController;

document.forms["benchmark-options"].addEventListener("change", () => { this.onBenchmarkOptionsChanged() }, true);
document.forms["benchmark-options"].addEventListener("change", (event) => { this.onBenchmarkOptionsChanged(event) }, true);
document.forms["graph-type"].addEventListener("change", () => { this.graphController.onGraphTypeChanged() }, true);
document.forms["time-graph-options"].addEventListener("change", () => { this.graphController.onTimeGraphOptionsChanged() }, true);
document.forms["complexity-graph-options"].addEventListener("change", () => { this.graphController.onComplexityGraphOptionsChanged() }, true);
Expand Down Expand Up @@ -593,13 +593,16 @@ class DebugBenchmarkController extends BenchmarkController {
var reader = new FileReader();
reader.filename = file.name;
reader.onload = (e) => {
var run = JSON.parse(e.target.result);
if (run.debugOutput instanceof Array)
run = run.debugOutput[0];
const data = JSON.parse(e.target.result);

let results;
if (data['debugOutput'] instanceof Array)
results = RunData.resultsDataFromBenchmarkRunnerData(data['debugOutput']);
else
results = RunData.resultsDataFromSingleRunData(data);

this.migrateImportedData(run);
this.ensureRunnerClient([ ], { });
this.runnerClient.results = new ResultsDashboard(run.version, run.options, run.data);
this.runnerClient.scoreCalculator = new ScoreCalculator(results);
this.showResults();
};

Expand All @@ -608,22 +611,6 @@ class DebugBenchmarkController extends BenchmarkController {
}, false);
}

migrateImportedData(runData)
{
if (!("version" in runData))
runData.version = "1.0";

if (!("frame-rate" in runData.options)) {
runData.options["frame-rate"] = 60;
console.log("No frame-rate data; assuming 60fps")
}

if (!("system-frame-rate" in runData.options)) {
runData.options["system-frame-rate"] = 60;
console.log("No system-frame-rate data; assuming 60fps")
}
}

frameRateDeterminationComplete(targetFrameRate)
{
let frameRateLabelContent = Strings.text.usingFrameRate.replace("%s", targetFrameRate);
Expand Down Expand Up @@ -704,38 +691,38 @@ class DebugBenchmarkController extends BenchmarkController {
this.addedKeyEvent = true;
}

var dashboard = this.runnerClient.results;
if (dashboard.options["controller"] == "ramp")
var scoreCalculator = this.runnerClient.scoreCalculator;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let?

if (scoreCalculator.options["controller"] == "ramp")
Headers.details[3].disabled = true;
else {
Headers.details[1].disabled = true;
Headers.details[4].disabled = true;
}

if (dashboard.options[Strings.json.configuration]) {
if (scoreCalculator.options[Strings.json.configuration]) {
document.body.classList.remove("small", "medium", "large");
document.body.classList.add(dashboard.options[Strings.json.configuration]);
document.body.classList.add(scoreCalculator.options[Strings.json.configuration]);
}

var score = dashboard.score;
var confidence = ((dashboard.scoreLowerBound / score - 1) * 100).toFixed(2) +
"% / +" + ((dashboard.scoreUpperBound / score - 1) * 100).toFixed(2) + "%";
var fps = dashboard._systemFrameRate;
sectionsManager.setSectionVersion("results", dashboard.version);
var score = scoreCalculator.score;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not const or let for these?

var confidence = ((scoreCalculator.scoreLowerBound / score - 1) * 100).toFixed(2) +
"% / +" + ((scoreCalculator.scoreUpperBound / score - 1) * 100).toFixed(2) + "%";
var fps = scoreCalculator._systemFrameRate;
sectionsManager.setSectionVersion("results", scoreCalculator.version);
sectionsManager.setSectionScore("results", score.toFixed(2), confidence, fps);
sectionsManager.populateTable("results-header", Headers.testName, dashboard);
sectionsManager.populateTable("results-score", Headers.score, dashboard);
sectionsManager.populateTable("results-data", Headers.details, dashboard);
sectionsManager.populateTable("results-header", Headers.testName, scoreCalculator);
sectionsManager.populateTable("results-score", Headers.score, scoreCalculator);
sectionsManager.populateTable("results-data", Headers.details, scoreCalculator);
sectionsManager.showSection("results", true);

suitesManager.updateLocalStorageFromJSON(dashboard.results[0]);
suitesManager.updateLocalStorageFromJSON(scoreCalculator.results[0]);
}

showTestGraph(testName, testResult, testData)
{
sectionsManager.setSectionHeader("test-graph", testName);
sectionsManager.showSection("test-graph", true);
this.graphController.updateGraphData(testResult, testData, this.runnerClient.results.options);
this.graphController.updateGraphData(testResult, testData, this.runnerClient.scoreCalculator.options);
}
}

Expand Down
Loading