Skip to content

Commit 93452be

Browse files
committed
Pre-computed tooltips implemented.
1 parent 3447b7a commit 93452be

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

html/benchmarks.js

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ $(function() {
6262
color: s[0],
6363
index: s[1],
6464
type: "column",
65-
data: stats.map(a => [a[0], a[3]]),
66-
atomic_queue_stats: stats,
65+
data: stats.map((a) => {
66+
const [min, max, mean, stdev] = a.slice(1).map(prec0);
67+
return {
68+
x: a[0],
69+
y: a[3],
70+
tooltip_row: `<tr><td style="color: ${s[0]}">${name}: </td><td><strong>${mean}</strong></td><td><strong>${stdev}</strong></td><td>${min}</td><td>${max}</td></tr>`
71+
};
72+
}),
6773
});
6874
series.push({
6975
name: `${name} StdDev`,
@@ -73,31 +79,17 @@ $(function() {
7379
});
7480
}
7581

76-
const tooltips = [];
7782
const tooltip_formatter = function() {
78-
const n_threads = this.x;
79-
const tooltip = tooltips[n_threads];
80-
if(tooltip)
81-
return tooltip;
82-
83-
const data = [];
84-
for(const p of this.points) {
85-
const [n_threads, min, max, mean, stdev] = p.series.options.atomic_queue_stats[p.point.index].map(prec0);
86-
data[p.series.options.index] = {
87-
name: p.series.name,
88-
color: p.series.color,
89-
min: min,
90-
max: max,
91-
mean: mean,
92-
stdev: stdev,
93-
};
94-
}
95-
const tbody = data.map((d) => `<tr><td style="color: ${d.color}">${d.name}: </td><td><strong>${d.mean}</strong></td><td><strong>${d.stdev}</strong></td><td>${d.min}</td><td>${d.max}</td></tr>`).join('\n')
96-
return tooltips[n_threads] = `
97-
<span class="tooltip_scalability_title">${n_threads} producers, ${n_threads} consumers</span>
83+
const { x, points } = this;
84+
const rows = points
85+
.map(point => point.options.tooltip_row)
86+
.join('\n');
87+
88+
return `
89+
<span class="tooltip_scalability_title">${x} producers, ${x} consumers</span>
9890
<table class="tooltip_scalability">
9991
<tr><th></th><th>mean</th><th>stdev</th><th>min</th><th>max</th></tr>
100-
${tbody}
92+
${rows}
10193
</table>
10294
`;
10395
};

0 commit comments

Comments
 (0)