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

Refactor MotionMark code #61

Open
wants to merge 1 commit 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
8 changes: 4 additions & 4 deletions MotionMark/about.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (C) 2015-2020 Apple Inc. All rights reserved.
Copyright (C) 2015-2024 Apple Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -30,14 +30,14 @@

<title>About MotionMark</title>

<link rel="stylesheet" href="resources/runner/motionmark.css">
<link rel="stylesheet" href="release/motionmark.css">

<script src="resources/strings.js"></script>
<script src="shared/strings.js"></script>
</head>
<body class="images-loaded">
<main>
<section id="about" class="selected">
<div class="logo"><svg><use xlink:href="resources/runner/logo.svg#root" /></svg></div>
<div class="logo"><svg><use xlink:href="release/logo.svg#root" /></svg></div>

<div class="body">
<h1>About MotionMark <span class="version"></span></h1>
Expand Down
132 changes: 132 additions & 0 deletions MotionMark/debug/complexity-graph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright (C) 2015-2024 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

class ComplexityGraph extends Graph {
constructor(run, settings, size, margins) {
super(run, settings);

let svg = this.appendGraph("complexity-graph", size, margins);

let xMin = d3.min(this.run.timeline.frames, (frame) => {
return frame.complexity;
});

let xMax = d3.max(this.run.timeline.frames, (frame) => {
return frame.complexity;
});

const yMin = Graph.msPerSecond / this.minFrameRate;
const yMax = Graph.msPerSecond / this.maxFrameRate;

const axisWidth = size.width - margins.left - margins.right;
const axisHeight = size.height - margins.top - margins.bottom;

let xScale = d3.scale.linear()
.range([0, axisWidth])
.domain([xMin, xMax]);

let yScale = d3.scale.linear()
.range([axisHeight, 0])
.domain([yMin, yMax]);

this.appendAxes(svg, xScale, yScale, axisHeight);
this.appendData(svg, xScale, yScale);
this.appendRegression(svg, xScale, yScale, xMin, xMax, this.run.statistics.regression);
}

appendAxes(svg, xScale, yScale, axisHeight) {
var xAxis = d3.svg.axis()
.scale(xScale)
.orient("bottom");

var yAxis = d3.svg.axis()
.scale(yScale)
.tickValues(this.tickValuesForFrameRate(this.settings.targetFrameRate, this.minFrameRate, this.maxFrameRate))
.tickFormat((d) => {
return (Graph.msPerSecond / d).toFixed(0);
})
.orient("left");

// x-axis
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + axisHeight + ")")
.call(xAxis);

// y-axis
var yAxisGroup = svg.append("g")
.attr("class", "y axis")
.call(yAxis);
}

appendData(svg, xScale, yScale) {
// series
let group = svg.append("g")
.attr("class", "series raw")
.selectAll("line")
.data(this.run.timeline.frames)
.enter();

group.append("line")
.attr("x1", (frame) => { return xScale(frame.complexity) - 3; })
.attr("x2", (frame) => { return xScale(frame.complexity) + 3; })
.attr("y1", (frame) => { return yScale(frame.timespan.length) - 3; })
.attr("y2", (frame) => { return yScale(frame.timespan.length) + 3; });

group.append("line")
.attr("x1", (frame) => { return xScale(frame.complexity) - 3; })
.attr("x2", (frame) => { return xScale(frame.complexity) + 3; })
.attr("y1", (frame) => { return yScale(frame.timespan.length) + 3; })
.attr("y2", (frame) => { return yScale(frame.timespan.length) - 3; });
}

appendLine(svg, xScale, yScale, point1, point2) {
svg.append("line")
.style("stroke", "white")
.style("stroke-width", 2)
.attr("x1", xScale(point1.x))
.attr("y1", yScale(point1.y))
.attr("x2", xScale(point2.x))
.attr("y2", yScale(point2.y));
}

appendRegression(svg, xScale, yScale, xMin, xMax, regression) {
let segment1 = regression.segment1;
let segment2 = regression.segment2;
let score = regression.score;

let point1 = new Point(xMin, segment1.s + segment1.t * xMin);
let point2 = new Point(score, segment1.s + segment1.t * score);
let point3 = new Point(xMax, segment2.s + segment2.t * xMax);

svg.append("circle")
.attr("cx", xScale(point2.x))
.attr("cy", yScale(point2.y))
.attr("r", 3);

this.appendLine(svg, xScale, yScale, point1, point2);
this.appendLine(svg, xScale, yScale, point2, point3);
}
}
File renamed without changes.
77 changes: 77 additions & 0 deletions MotionMark/debug/debug-fixed-results.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2015-2024 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

class DebugFixedResults extends DebugResults {
descriptors = [
{
text: Strings.text.timeComplexity,
columns:
[
{
text: (statistics) => {
return statistics.timeScore.toFixed(2);
},
className: "average"
},
{
text: (statistics) => {
let stdevTimeScorePercent = statistics.timeScore ? statistics.timeScoreStdev * 100 / statistics.timeScore : 0;
return "± " + stdevTimeScorePercent.toFixed(2) + "%";
},
className: (statistics) => {
let stdevTimeScorePercent = statistics.timeScore ? statistics.timeScoreStdev * 100 / statistics.timeScore : 0;
return stdevTimeScorePercent >= 10 ? "stdev noisy-results" : "stdev";
}
}
]
},
{
text: Strings.text.FPS,
columns:
[
{
text: (statistics) => {
return statistics.averageFrameRate.toFixed(2);
},
className: (statistics) => {
return Math.abs(statistics.averageFrameRate - settings.targetFrameRate) < 2 ? "average" : "average noisy-results";
}
},
{
text: (statistics) => {
return "± " + statistics.stdevFrameRatePercent.toFixed(2) + "%";
},
className: (statistics) => {
return statistics.stdevFrameRatePercent < 10 ? "stdev" : "stdev noisy-results";
}
}
]
}
];

populateRunsDetails() {
this.populateRunsTable(this.descriptors);
}
}
Loading