From a73ffca3a4ae7e6d15d39cecee60fe85814bc156 Mon Sep 17 00:00:00 2001 From: Zeynep Cankara Date: Wed, 2 Sep 2020 13:14:18 +0100 Subject: [PATCH] [tools][system-analyzer] Find Unique IC/Map types and improve Map panel This CL enables showing map details of the selected map coming from FocusEvent. It also improves UI experience of selecting a map from map transitions, highlighting selected map. Additionally, stores information about unique map/IC events in model for the timeline-track legend. Bug: v8:10644 Change-Id: Ieb8a2ac0bf1af282d55bce18130192d7178538da Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2387564 Reviewed-by: Camillo Bruni Reviewed-by: Sathya Gunasekaran Commit-Queue: Zeynep Cankara Cr-Commit-Position: refs/heads/master@{#69673} --- .../map-panel/map-transitions.mjs | 1 + tools/system-analyzer/timeline.mjs | 19 +++++++++++++++++++ .../timeline/timeline-track.mjs | 18 +++--------------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/tools/system-analyzer/map-panel/map-transitions.mjs b/tools/system-analyzer/map-panel/map-transitions.mjs index 0ed2cc22e7..d508b88694 100644 --- a/tools/system-analyzer/map-panel/map-transitions.mjs +++ b/tools/system-analyzer/map-panel/map-transitions.mjs @@ -47,6 +47,7 @@ defineCustomElement( selectMap(map) { this.currentMap = map; + this.showMap(); this.dispatchEvent(new FocusEvent(map)); } diff --git a/tools/system-analyzer/timeline.mjs b/tools/system-analyzer/timeline.mjs index 3885b98185..977e0bb2b6 100644 --- a/tools/system-analyzer/timeline.mjs +++ b/tools/system-analyzer/timeline.mjs @@ -5,6 +5,7 @@ class Timeline { #values; #selection; + #uniqueTypes; constructor() { this.#values = []; this.startTime = 0; @@ -86,6 +87,24 @@ class Timeline { return this.last().time - this.first().time; } + groupByTypes() { + this.#uniqueTypes = new Map(); + for (const entry of this.all) { + if (!this.#uniqueTypes.has(entry.type)) { + this.#uniqueTypes.set(entry.type, [entry]); + } else { + this.#uniqueTypes.get(entry.type).push(entry); + } + } + } + + get uniqueTypes() { + if (this.#uniqueTypes === undefined) { + this.groupByTypes(); + } + return this.#uniqueTypes; + } + forEachChunkSize(count, fn) { const increment = this.duration() / count; let currentTime = this.first().time + increment; diff --git a/tools/system-analyzer/timeline/timeline-track.mjs b/tools/system-analyzer/timeline/timeline-track.mjs index 86e8201b79..1a286f37d6 100644 --- a/tools/system-analyzer/timeline/timeline-track.mjs +++ b/tools/system-analyzer/timeline/timeline-track.mjs @@ -159,7 +159,7 @@ defineCustomElement('./timeline/timeline-track', (templateText) => this.#timeline = value; this.updateChunks(); this.updateTimeline(); - this.updateLegend(); + this.renderLegend(); } get data() { @@ -191,20 +191,8 @@ defineCustomElement('./timeline/timeline-track', (templateText) => set scrollLeft(offset) { this.timeline.scrollLeft = offset; } - //TODO(zcankara) Carry to the Model, nothing UI related - updateLegend() { - const uniqueTypes = new Map(); - for (const entry of this.data.all) { - if (!uniqueTypes.has(entry.type)) { - uniqueTypes.set(entry.type, [entry]); - } else { - uniqueTypes.get(entry.type).push(entry); - } - } - this.renderLegend(uniqueTypes); - } - renderLegend(uniqueTypes) { + renderLegend() { let timelineLegend = this.timelineLegend; let timelineLegendContent = this.timelineLegendContent; this.removeAllChildren(timelineLegendContent); @@ -219,7 +207,7 @@ defineCustomElement('./timeline/timeline-track', (templateText) => row.appendChild(this.td("100%")); timelineLegendContent.appendChild(row); let colorIterator = 0; - uniqueTypes.forEach((entries, type) => { + this.#timeline.uniqueTypes.forEach((entries, type) => { let row = this.tr(); row.entries = entries; row.classList.add('clickable');