Commit 06d8f6fa authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[object-stats] Visualizer: Allow filtering categories by used memory

Tbr: ulan@chromium.org
No-try: true
Bug: v8:7266
Change-Id: Ia0965fa085d8d92b65a9353174e123337dc1ef6b
Reviewed-on: https://chromium-review.googlesource.com/888585Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50908}
parent 0e2a2808
...@@ -49,6 +49,12 @@ found in the LICENSE file. --> ...@@ -49,6 +49,12 @@ found in the LICENSE file. -->
#categories { #categories {
margin-top: 10px; margin-top: 10px;
} }
#category-filter {
text-align: right;
width: 50px;
}
</style> </style>
<h2>Data selection</h2> <h2>Data selection</h2>
<ul> <ul>
...@@ -83,7 +89,11 @@ found in the LICENSE file. --> ...@@ -83,7 +89,11 @@ found in the LICENSE file. -->
</select> </select>
</li> </li>
<li> <li>
<button id="csv-export" disabled="disabled">Export selection as CSV</button> <input id="category-filter" type="text" value="0" disabled="disabled" />KB
<button id="category-filter-btn" disabled="disabled">Filter categories with less memory</button>
</li>
<li>
<button id="csv-export-btn" disabled="disabled">Export selection as CSV</button>
</li> </li>
</ul> </ul>
......
...@@ -19,10 +19,12 @@ class DetailsSelection extends HTMLElement { ...@@ -19,10 +19,12 @@ class DetailsSelection extends HTMLElement {
'change', e => this.notifySelectionChanged(e)); 'change', e => this.notifySelectionChanged(e));
this.gcSelect.addEventListener( this.gcSelect.addEventListener(
'change', e => this.notifySelectionChanged(e)); 'change', e => this.notifySelectionChanged(e));
this.$('#csv-export') this.$('#csv-export-btn')
.addEventListener('click', e => this.exportCurrentSelection(e)); .addEventListener('click', e => this.exportCurrentSelection(e));
this.$('#merge-categories') this.$('#merge-categories')
.addEventListener('change', e => this.notifySelectionChanged(e)); .addEventListener('change', e => this.notifySelectionChanged(e));
this.$('#category-filter-btn')
.addEventListener('click', e => this.filterCurrentSeclection(e));
} }
connectedCallback() { connectedCallback() {
...@@ -108,7 +110,9 @@ class DetailsSelection extends HTMLElement { ...@@ -108,7 +110,9 @@ class DetailsSelection extends HTMLElement {
removeAllChildren(this.datasetSelect); removeAllChildren(this.datasetSelect);
removeAllChildren(this.gcSelect); removeAllChildren(this.gcSelect);
this.clearCategories(); this.clearCategories();
this.$('#csv-export').disabled = 'disabled'; this.$('#csv-export-btn').disabled = 'disabled';
this.$('#category-filter-btn').disabled = 'disabled';
this.$('#category-filter').disabled = 'disabled';
} }
handleIsolateChange(e) { handleIsolateChange(e) {
...@@ -141,12 +145,29 @@ class DetailsSelection extends HTMLElement { ...@@ -141,12 +145,29 @@ class DetailsSelection extends HTMLElement {
this.selection.data_set = this.datasetSelect.value; this.selection.data_set = this.datasetSelect.value;
this.selection.merge_categories = this.$('#merge-categories').checked; this.selection.merge_categories = this.$('#merge-categories').checked;
this.selection.gc = this.gcSelect.value; this.selection.gc = this.gcSelect.value;
this.$('#csv-export').disabled = false; this.$('#csv-export-btn').disabled = false;
this.$('#category-filter-btn').disabled = false;
this.$('#category-filter').disabled = false;
this.updatePercentagesInCategory(); this.updatePercentagesInCategory();
this.dispatchEvent(new CustomEvent( this.dispatchEvent(new CustomEvent(
'change', {bubbles: true, composed: true, detail: this.selection})); 'change', {bubbles: true, composed: true, detail: this.selection}));
} }
filterCurrentSeclection(e) {
const filter_value = this.$('#category-filter').value * KB;
if (filter_value === 0) return;
this.selection.category_names.forEach((_, category) => {
for (let checkbox of this.shadowRoot.querySelectorAll(
'input[name=' + category + 'Checkbox]')) {
checkbox.checked =
this.selectedData.instance_type_data[checkbox.instance_type]
.overall > filter_value;
}
});
this.notifySelectionChanged();
}
updatePercentagesInCategory() { updatePercentagesInCategory() {
const overalls = {}; const overalls = {};
let overall = 0; let overall = 0;
...@@ -257,6 +278,7 @@ class DetailsSelection extends HTMLElement { ...@@ -257,6 +278,7 @@ class DetailsSelection extends HTMLElement {
input.name = category + 'Checkbox'; input.name = category + 'Checkbox';
input.checked = 'checked'; input.checked = 'checked';
input.id = instance_type + 'Checkbox'; input.id = instance_type + 'Checkbox';
input.instance_type = instance_type;
input.value = instance_type; input.value = instance_type;
input.addEventListener('change', e => this.notifySelectionChanged(e)); input.addEventListener('change', e => this.notifySelectionChanged(e));
const label = document.createElement('label'); const label = document.createElement('label');
......
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