Skip to content

Commit ff00967

Browse files
committed
Fix instability in the Design subtest
The Design subtest projects out copies of a `<table>` along a ray, where the step between copies is constant, so the longest distance increases with test complexity. At higher complexities, this results in clipping at the document boundary. This clipping makes rendering additional copies cheap (since they are clipped out), which can result in the test computing artificially high complexities. This results in noisy or inaccurate test scores. Fix by using a max distance computed from the height of the template element, and then spacing out the copies out to that distance. This ensures that all copies are inside the viewport. Adjust the layout, shrinking the table vertically a little so there's more space for copies above and below, where it tends to clip. #24
1 parent 3090053 commit ff00967

File tree

2 files changed

+34
-30
lines changed

2 files changed

+34
-30
lines changed

MotionMark/tests/core/design.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
<meta charset="utf-8">
2929
<link rel="stylesheet" type="text/css" href="../resources/stage.css">
3030
<style type="text/css">
31-
3231
#stage {
3332
font-family: Helvetica;
3433
font-size: 52px;
3534
background-color: #313534;
3635
}
36+
3737
@media (max-width: 900px) {
3838
#stage {
3939
font-size: 40px;
@@ -56,14 +56,15 @@
5656
}
5757
table {
5858
position: relative;
59+
top: 10%;
5960
width: 100%;
60-
height: 100%;
61+
height: 80%;
6162
}
6263
td {
6364
width: 33%;
6465
}
6566
tr {
66-
height: 20%;
67+
height: 12%;
6768
}
6869
</style>
6970
</head>

MotionMark/tests/core/resources/design.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ var TextStage = Utilities.createSubclass(Stage,
5454
Stage.prototype.initialize.call(this, benchmark);
5555

5656
this._template = document.getElementById("template");
57-
this._offset = this.size.subtract(Point.elementClientSize(this._template)).multiply(.5);
57+
58+
const templateSize = Point.elementClientSize(this._template);
59+
this._offset = this.size.subtract(templateSize).multiply(.5);
60+
this._maxOffset = templateSize.height / 4;
61+
5862
this._template.style.left = this._offset.width + "px";
5963
this._template.style.top = this._offset.height + "px";
6064

@@ -68,7 +72,7 @@ var TextStage = Utilities.createSubclass(Stage,
6872

6973
if (count < 0) {
7074
this._offsetIndex = Math.max(this._offsetIndex + count, 0);
71-
for (var i = this._offsetIndex; i < this.testElements.length; ++i)
75+
for (let i = this._offsetIndex; i < this.testElements.length; ++i)
7276
this.testElements[i].style.visibility = "hidden";
7377

7478
this._stepProgress = 1 / this._offsetIndex;
@@ -78,44 +82,43 @@ var TextStage = Utilities.createSubclass(Stage,
7882
this._offsetIndex = this._offsetIndex + count;
7983
this._stepProgress = 1 / this._offsetIndex;
8084

81-
var index = Math.min(this._offsetIndex, this.testElements.length);
82-
for (var i = 0; i < index; ++i)
85+
const index = Math.min(this._offsetIndex, this.testElements.length);
86+
for (let i = 0; i < index; ++i)
8387
this.testElements[i].style.visibility = "visible";
8488

8589
if (this._offsetIndex <= this.testElements.length)
8690
return;
8791

88-
for (var i = this.testElements.length; i < this._offsetIndex; ++i) {
89-
var clone = this._template.cloneNode(true);
92+
for (let i = this.testElements.length; i < this._offsetIndex; ++i) {
93+
const clone = this._template.cloneNode(true);
9094
this.testElements.push(clone);
9195
this.element.insertBefore(clone, this.element.firstChild);
9296
}
9397
},
9498

95-
animate: function(timeDelta) {
96-
var angle = Stage.dateCounterValue(this.millisecondsPerRotation);
97-
98-
var progress = 0;
99-
var stepX = Math.sin(angle) * this.particleDistanceX;
100-
var stepY = Math.cos(angle) * this.particleDistanceY;
101-
var x = -stepX * 3;
102-
var y = -stepY * 3;
103-
var gradient = this.gradients[Math.floor(angle/(Math.PI * 2)) % this.gradients.length];
104-
var offset = Stage.dateCounterValue(200);
105-
this._template.style.transform = "translate(" + Math.floor(x) + "px," + Math.floor(y) + "px)";
106-
for (var i = 0; i < this._offsetIndex; ++i) {
107-
var element = this.testElements[i];
108-
109-
var colorProgress = this.shadowFalloff.solve(progress);
110-
var shimmer = Math.sin(offset - colorProgress);
99+
animate: function(timeDelta)
100+
{
101+
const angle = Stage.dateCounterValue(this.millisecondsPerRotation);
102+
103+
const gradient = this.gradients[Math.floor(angle / (Math.PI * 2)) % this.gradients.length];
104+
const offset = Stage.dateCounterValue(200);
105+
const maxX = Math.sin(angle) * this._maxOffset;
106+
const maxY = Math.cos(angle) * this._maxOffset;
107+
108+
let progress = 0;
109+
for (let i = 0; i < this._offsetIndex; ++i) {
110+
const element = this.testElements[i];
111+
112+
let colorProgress = this.shadowFalloff.solve(progress);
113+
const shimmer = Math.sin(offset - colorProgress);
111114
colorProgress = Math.max(Math.min(colorProgress + Utilities.lerp(shimmer, this.shimmerAverage, this.shimmerMax), 1), 0);
112-
var r = Math.round(Utilities.lerp(colorProgress, gradient[0], gradient[3]));
113-
var g = Math.round(Utilities.lerp(colorProgress, gradient[1], gradient[4]));
114-
var b = Math.round(Utilities.lerp(colorProgress, gradient[2], gradient[5]));
115+
const r = Math.round(Utilities.lerp(colorProgress, gradient[0], gradient[3]));
116+
const g = Math.round(Utilities.lerp(colorProgress, gradient[1], gradient[4]));
117+
const b = Math.round(Utilities.lerp(colorProgress, gradient[2], gradient[5]));
115118
element.style.color = "rgb(" + r + "," + g + "," + b + ")";
116119

117-
x += stepX;
118-
y += stepY;
120+
const x = Utilities.lerp(i / this._offsetIndex, 0, maxX);
121+
const y = Utilities.lerp(i / this._offsetIndex, 0, maxY);
119122
element.style.transform = "translate(" + Math.floor(x) + "px," + Math.floor(y) + "px)";
120123

121124
progress += this._stepProgress;

0 commit comments

Comments
 (0)