Skip to content

Commit 10479ab

Browse files
Eduardo YapSkCQ
authored andcommitted
Group anomalies into groups based on revision overlap.
Also fix issue where buttons were not hidden when displaying an anomaly group. Bug: b/374810973 Change-Id: Ic5406c3fffc73dc6bdfc6fd594fa114fc2bd92ce Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/917319 Commit-Queue: Eduardo Yap <[email protected]> Reviewed-by: Wenbin Zhang <[email protected]>
1 parent 5e9a28e commit 10479ab

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

perf/modules/anomalies-table-sk/anomalies-table-sk-demo.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ const anomaly_table = [
125125
},
126126
];
127127

128-
window.customElements.whenDefined('anomalies-table-sk').then(async () => {
129-
// await load({ packages: ['table'] });
130-
});
131-
132128
$$('#populate-tables')?.addEventListener('click', () => {
133129
document.querySelectorAll<AnomaliesTableSk>('anomalies-table-sk').forEach((ele) => {
134130
ele.populateTable(anomaly_table);

perf/modules/anomalies-table-sk/anomalies-table-sk.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ anomalies-table-sk {
66
display: block;
77
padding: 16px;
88

9+
.expand-button[hidden] {
10+
display: none;
11+
}
12+
913
> dialog {
1014
z-index: 2;
1115
background: var(--background);

perf/modules/anomalies-table-sk/anomalies-table-sk.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,49 @@ export class AnomaliesTableSk extends ElementSk {
3838

3939
private static template = (ele: AnomaliesTableSk) => html` ${ele.generateTable()} `;
4040

41+
private rangeIntersects(aMin: number, aMax: number, bMin: number, bMax: number) {
42+
return aMin <= bMax && bMin <= aMax;
43+
}
44+
45+
private shouldMerge(a: Anomaly, b: Anomaly) {
46+
return this.rangeIntersects(a.start_revision, a.end_revision, b.start_revision, b.end_revision);
47+
}
48+
49+
/**
50+
* Merge anomalies into groups.
51+
*
52+
* The criteria for merging two anomalies A and B is if A.start_revision and A.end_revision
53+
* intersect with B.start_revision and B.end_revision.
54+
*/
4155
private groupAnomalies() {
42-
this.anomalyGroups = [];
56+
const groups = [];
4357

44-
// TODO(eduardoyap): Modify logic to group anomalies correctly.
4558
for (let i = 0; i < this.anomalyList.length; i++) {
59+
let merged = false;
4660
const anomaly = this.anomalyList[i];
47-
this.anomalyGroups.push({
48-
anomalies: [anomaly, anomaly],
49-
expanded: false,
50-
});
61+
for (const group of groups) {
62+
let doMerge = true;
63+
for (const other of group.anomalies) {
64+
const should = this.shouldMerge(anomaly, other);
65+
if (!should) {
66+
doMerge = false;
67+
break;
68+
}
69+
}
70+
if (doMerge) {
71+
group.anomalies.push(anomaly);
72+
merged = true;
73+
break;
74+
}
75+
}
76+
if (!merged) {
77+
groups.push({
78+
anomalies: [anomaly],
79+
expanded: false,
80+
});
81+
}
5182
}
83+
this.anomalyGroups = groups;
5284
}
5385

5486
private generateTable() {
@@ -92,7 +124,10 @@ export class AnomaliesTableSk extends ElementSk {
92124
rows.push(html`
93125
<tr ?hidden=${!anomalyGroup.expanded && i !== 0}>
94126
<td>
95-
<button @click=${() => this.expandGroup(anomalyGroup)} ?hidden=${length === 1 || i > 0}>
127+
<button
128+
class="expand-button"
129+
@click=${() => this.expandGroup(anomalyGroup)}
130+
?hidden=${length === 1 || i > 0}>
96131
${length}
97132
</button>
98133
</td>

0 commit comments

Comments
 (0)