Skip to content

Commit b065e59

Browse files
authored
Merge pull request #254 from kmiller68/scatter-plot-should-increase-with-score
The Scatter Plot Should Increase with the Score
2 parents b043058 + e12665f commit b065e59

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

JetStreamDriver.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,24 +1240,25 @@ class Benchmark {
12401240
if (!plotContainer || !this.results || this.results.length === 0)
12411241
return;
12421242

1243+
const scores = this.results.map(time => toScore(time));
12431244
const scoreElement = document.getElementById(this.scoreIdentifier("Score"));
12441245
const width = scoreElement.offsetWidth;
12451246
const height = scoreElement.offsetHeight;
12461247

12471248
const padding = 5;
1248-
const maxResult = Math.max(...this.results);
1249-
const minResult = Math.min(...this.results);
1249+
const maxResult = Math.max(...scores);
1250+
const minResult = Math.min(...scores);
12501251

1251-
const xRatio = (width - 2 * padding) / (this.results.length - 1 || 1);
1252+
const xRatio = (width - 2 * padding) / (scores.length - 1 || 1);
12521253
const yRatio = (height - 2 * padding) / (maxResult - minResult || 1);
12531254
const radius = Math.max(1.5, Math.min(2.5, 10 - (this.iterations / 10)));
12541255

12551256
let circlesSVG = "";
1256-
for (let i = 0; i < this.results.length; i++) {
1257-
const result = this.results[i];
1257+
for (let i = 0; i < scores.length; i++) {
1258+
const result = scores[i];
12581259
const cx = padding + i * xRatio;
12591260
const cy = height - padding - (result - minResult) * yRatio;
1260-
const title = `Iteration ${i + 1}: ${uiFriendlyDuration(result)}`;
1261+
const title = `Iteration ${i + 1}: ${uiFriendlyScore(result)} (${uiFriendlyDuration(this.results[i])})`;
12611262
circlesSVG += `<circle cx="${cx}" cy="${cy}" r="${radius}"><title>${title}</title></circle>`;
12621263
}
12631264
plotContainer.innerHTML = `<svg width="${width}px" height="${height}px">${circlesSVG}</svg>`;

0 commit comments

Comments
 (0)