Commit ebbc6070 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[tools] Various fixes for callstats.html

- sort group entries properly
- show graphs by default
- do not render the graphs twice

Change-Id: I8af48b5ddf87aad3dd17bc856b7a0f883ee41058

NOTRY=true

Change-Id: I8af48b5ddf87aad3dd17bc856b7a0f883ee41058
Reviewed-on: https://chromium-review.googlesource.com/447977
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43530}
parent 0ce9e1e8
...@@ -360,11 +360,11 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -360,11 +360,11 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
var page = version.get(state.page); var page = version.get(state.page);
if (!page) return false; if (!page) return false;
if (!state.entry) { if (!state.entry) {
showPage(page); showEntry(page.total);
} else { } else {
var entry = page.get(state.entry); var entry = page.get(state.entry);
if (!entry) { if (!entry) {
showPage(page); showEntry(page.total);
} else { } else {
showEntry(entry); showEntry(entry);
} }
...@@ -386,10 +386,16 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -386,10 +386,16 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
window.history.pushState(state, selection.toString(), params); window.history.pushState(state, selection.toString(), params);
} }
function showSelectedEntryInPage(page) {
if (!selectedEntry) return showPage(page);
var entry = page.get(selectedEntry.name);
if (!entry) return showPage(page);
selectEntry(entry);
}
function showPage(firstPage) { function showPage(firstPage) {
var changeSelectedEntry = selectedEntry !== undefined var changeSelectedEntry = selectedEntry !== undefined
&& selectedEntry.page === selectedPage; && selectedEntry.page === selectedPage;
pushHistoryState();
selectedPage = firstPage; selectedPage = firstPage;
selectedPage.sort(); selectedPage.sort();
showPageInColumn(firstPage, 0); showPageInColumn(firstPage, 0);
...@@ -487,14 +493,14 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -487,14 +493,14 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
td(tr, '-', 'position'); td(tr, '-', 'position');
td(tr, referenceEntry.name, 'name'); td(tr, referenceEntry.name, 'name');
diffStatus( diffStatus(
td(tr, ms(-referenceEntry.time), 'value time'), td(tr, ms(referenceEntry.time), 'value time'),
-referenceEntry.time, 0); referenceEntry.time, 0);
diffStatus( diffStatus(
td(tr, percent(-referenceEntry.timePercent), 'value time'), td(tr, percent(referenceEntry.timePercent), 'value time'),
-referenceEntry.timePercent, 0); referenceEntry.timePercent, 0);
diffStatus( diffStatus(
td(tr, count(-referenceEntry.count), 'value count'), td(tr, count(referenceEntry.count), 'value count'),
-referenceEntry.count, 0); referenceEntry.count, 0);
} else { } else {
// Display empty entry / baseline entry // Display empty entry / baseline entry
var showBaselineEntry = entry !== undefined; var showBaselineEntry = entry !== undefined;
...@@ -526,16 +532,16 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -526,16 +532,16 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
} }
function showEntry(entry) { function showEntry(entry) {
selectedEntry = entry;
selectEntry(entry, true); selectEntry(entry, true);
} }
function selectEntry(entry, updateSelectedPage) { function selectEntry(entry, updateSelectedPage) {
if (updateSelectedPage) { var needsPageSwitch = true;
if (updateSelectedPage && selectedPage) {
entry = selectedPage.version.getEntry(entry); entry = selectedPage.version.getEntry(entry);
needsPageSwitch = updateSelectedPage && entry.page != selectedPage;
} }
var rowIndex = 0; var rowIndex = 0;
var needsPageSwitch = updateSelectedPage && entry.page != selectedPage;
// If clicked in the detail row change the first column to that page. // If clicked in the detail row change the first column to that page.
if (needsPageSwitch) showPage(entry.page); if (needsPageSwitch) showPage(entry.page);
var childNodes = $('column_0').querySelector('.list tbody').childNodes; var childNodes = $('column_0').querySelector('.list tbody').childNodes;
...@@ -561,11 +567,13 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -561,11 +567,13 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
toggleCssClass(row, 'selected', row.entry && row.entry.name == toggleCssClass(row, 'selected', row.entry && row.entry.name ==
firstEntry.name); firstEntry.name);
}); });
if (updateSelectedPage) { if (updateSelectedPage && selectedEntry) {
entry = selectedEntry.page.version.getEntry(entry); entry = selectedEntry.page.version.getEntry(entry);
} }
selectedEntry = entry; if (entry !== selectedEntry) {
showEntryDetail(entry); selectedEntry = entry;
showEntryDetail(entry);
}
} }
function showEntryDetail(entry) { function showEntryDetail(entry) {
...@@ -1119,9 +1127,8 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1119,9 +1127,8 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
pages = new Pages(); pages = new Pages();
versions = Versions.fromJSON(json); versions = Versions.fromJSON(json);
initialize() initialize()
showPage(versions.versions[0].pages[0]);
if (!popHistoryState(state)) { if (!popHistoryState(state)) {
selectEntry(selectedPage.total); showEntry(selectedPage.total);
} }
} }
...@@ -1133,7 +1140,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1133,7 +1140,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
function handleSelectPage(select, event) { function handleSelectPage(select, event) {
var option = select.options[select.selectedIndex]; var option = select.options[select.selectedIndex];
if (select.id == "select_0") { if (select.id == "select_0") {
showPage(option.page); showSelectedEntryInPage(option.page);
} else { } else {
var columnIndex = select.id.split('_')[1]; var columnIndex = select.id.split('_')[1];
showPageInColumn(option.page, columnIndex); showPageInColumn(option.page, columnIndex);
...@@ -1145,7 +1152,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1145,7 +1152,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
var version = option.version; var version = option.version;
if (select.id == "selectVersion_0") { if (select.id == "selectVersion_0") {
var page = version.get(selectedPage.name); var page = version.get(selectedPage.name);
showPage(page); showSelectedEntryInPage(page);
} else { } else {
var columnIndex = select.id.split('_')[1]; var columnIndex = select.id.split('_')[1];
var pageSelect = $('select_' + columnIndex); var pageSelect = $('select_' + columnIndex);
...@@ -1668,6 +1675,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1668,6 +1675,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
super(0, GroupedEntry.prefix + group.name, 0, 0, 0, 0, 0, 0); super(0, GroupedEntry.prefix + group.name, 0, 0, 0, 0, 0, 0);
this.group = group; this.group = group;
this.entries = []; this.entries = [];
this.missingEntries = null;
} }
get regexp() { return this.group.regexp } get regexp() { return this.group.regexp }
get color() { return this.group.color } get color() { return this.group.color }
...@@ -1681,8 +1689,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1681,8 +1689,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
entry.parent = this; entry.parent = this;
return true; return true;
} }
forEach(fun) { _initializeMissingEntries() {
// Show also all entries which are in at least one version.
var dummyEntryNames = new Set(); var dummyEntryNames = new Set();
versions.forEach((version) => { versions.forEach((version) => {
var groupEntry = version.getEntry(this); var groupEntry = version.getEntry(this);
...@@ -1694,19 +1701,25 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1694,19 +1701,25 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
} }
} }
}); });
var tmpEntries = []; this.missingEntries = [];
for (var name of dummyEntryNames) { for (var name of dummyEntryNames) {
var tmpEntry = new Entry(0, name, 0, 0, 0, 0, 0, 0); var tmpEntry = new Entry(0, name, 0, 0, 0, 0, 0, 0);
tmpEntry.page = this.page; tmpEntry.page = this.page;
tmpEntries.push(tmpEntry); this.missingEntries.push(tmpEntry);
}; };
}
forEach(fun) {
// Show also all entries which are in at least one version.
// Concatenate our real entries. // Concatenate our real entries.
tmpEntries = tmpEntries.concat(this.entries); if (this.missingEntries == null) {
this._initializeMissingEntries();
}
var tmpEntries = this.missingEntries.concat(this.entries);
// The compared entries are sorted by absolute impact. // The compared entries are sorted by absolute impact.
tmpEntries.sort((a, b) => { tmpEntries.sort((a, b) => {
return a.time - b.time return b.time - a.time
}); });
tmpEntries.forEach(fun); tmpEntries.forEach(fun);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment