diff options
Diffstat (limited to 'deps/v8/tools/callstats.html')
-rw-r--r-- | deps/v8/tools/callstats.html | 206 |
1 files changed, 142 insertions, 64 deletions
diff --git a/deps/v8/tools/callstats.html b/deps/v8/tools/callstats.html index 76cc8c686d..cb2e0bea3e 100644 --- a/deps/v8/tools/callstats.html +++ b/deps/v8/tools/callstats.html @@ -247,8 +247,12 @@ code is governed by a BSD-style license that can be found in the LICENSE file. var selectedPage; var baselineVersion; var selectedEntry; + + // Marker to programatically replace the defaultData. + var defaultData = /*default-data-start*/undefined/*default-data-end*/; function initialize() { + // Initialize the stats table and toggle lists. var original = $("column"); var view = document.createElement('div'); view.id = 'view'; @@ -303,6 +307,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. }); initializeToggleList(versions.versions, $('versionSelector')); initializeToggleList(pages.values(), $('pageSelector')); + initializeToggleList(Group.groups.values(), $('groupSelector')); initializeToggleContentVisibility(); } @@ -317,7 +322,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. checkbox.type = 'checkbox'; checkbox.checked = item.enabled; checkbox.item = item; - checkbox.addEventListener('click', handleToggleVersionEnable); + checkbox.addEventListener('click', handleToggleVersionOrPageEnable); li.appendChild(checkbox); li.appendChild(document.createTextNode(item.name)); list.appendChild(li); @@ -360,9 +365,8 @@ code is governed by a BSD-style license that can be found in the LICENSE file. }); if (changeSelectedEntry) { showEntryDetail(selectedPage.getEntry(selectedEntry)); - } else { - showImpactList(selectedPage); } + showImpactList(selectedPage); } function showPageInColumn(page, columnIndex) { @@ -536,7 +540,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. table = $('detailView').querySelector('.versionDetailTable'); tbody = document.createElement('tbody'); if (entry !== undefined) { - $('detailView').querySelector('.versionDetail h3 span').innerHTML = + $('detailView').querySelector('.versionDetail h3 span').textContent = entry.name + ' in ' + entry.page.name; entries = versions.getPageVersions(entry.page).map( (page) => { @@ -571,7 +575,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. } var version = entry.page.version; var showDiff = version !== baselineVersion; - $('detailView').querySelector('.pageDetail h3 span').innerHTML = + $('detailView').querySelector('.pageDetail h3 span').textContent = version.name; entries = version.pages.map((page) => { if (!page.enabled) return; @@ -597,24 +601,24 @@ code is governed by a BSD-style license that can be found in the LICENSE file. }); // show the total for all pages var tds = table.querySelectorAll('tfoot td'); - tds[1].innerHTML = ms(entry.getTimeImpact(), showDiff); + tds[1].textContent = ms(entry.getTimeImpact(), showDiff); // Only show the percentage total if we are in diff mode: - tds[2].innerHTML = percent(entry.getTimePercentImpact(), showDiff); - tds[3].innerHTML = ''; - tds[4].innerHTML = count(entry.getCountImpact(), showDiff); + tds[2].textContent = percent(entry.getTimePercentImpact(), showDiff); + tds[3].textContent = ''; + tds[4].textContent = count(entry.getCountImpact(), showDiff); table.replaceChild(tbody, table.querySelector('tbody')); } function showImpactList(page) { var impactView = $('detailView').querySelector('.impactView'); - impactView.querySelector('h3 span').innerHTML = page.version.name; + impactView.querySelector('h3 span').textContent = page.version.name; var table = impactView.querySelector('table'); var tbody = document.createElement('tbody'); var version = page.version; var entries = version.allEntries(); if (selectedEntry !== undefined && selectedEntry.isGroup) { - impactView.querySelector('h3 span').innerHTML += " " + selectedEntry.name; + impactView.querySelector('h3 span').textContent += " " + selectedEntry.name; entries = entries.filter((entry) => { return entry.name == selectedEntry.name || (entry.parent && entry.parent.name == selectedEntry.name) @@ -662,7 +666,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. if (selectedGroup == undefined) { selectedGroup = groups[0]; } else { - groups = groups.filter(each => each.name != selectedGroup.name); + groups = groups.filter(each => each.enabled && each.name != selectedGroup.name); groups.unshift(selectedGroup); } showPageGraph(groups, page); @@ -806,7 +810,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. colors: groups.map(each => each.color) }; var parentNode = $(id); - parentNode.querySelector('h2>span, h3>span').innerHTML = title; + parentNode.querySelector('h2>span, h3>span').textContent = title; var graphNode = parentNode.querySelector('.content'); var chart = graphNode.chart; @@ -856,8 +860,8 @@ code is governed by a BSD-style license that can be found in the LICENSE file. function showPopover(entry) { var popover = $('popover'); - popover.querySelector('td.name').innerHTML = entry.name; - popover.querySelector('td.page').innerHTML = entry.page.name; + popover.querySelector('td.name').textContent = entry.name; + popover.querySelector('td.page').textContent = entry.page.name; setPopoverDetail(popover, entry, ''); popover.querySelector('table').className = ""; if (baselineVersion !== undefined) { @@ -870,32 +874,32 @@ code is governed by a BSD-style license that can be found in the LICENSE file. function setPopoverDetail(popover, entry, prefix) { var node = (name) => popover.querySelector(prefix + name); if (entry == undefined) { - node('.version').innerHTML = baselineVersion.name; - node('.time').innerHTML = '-'; - node('.timeVariance').innerHTML = '-'; - node('.percent').innerHTML = '-'; - node('.percentPerEntry').innerHTML = '-'; - node('.percentVariance').innerHTML = '-'; - node('.count').innerHTML = '-'; - node('.countVariance').innerHTML = '-'; - node('.timeImpact').innerHTML = '-'; - node('.timePercentImpact').innerHTML = '-'; + node('.version').textContent = baselineVersion.name; + node('.time').textContent = '-'; + node('.timeVariance').textContent = '-'; + node('.percent').textContent = '-'; + node('.percentPerEntry').textContent = '-'; + node('.percentVariance').textContent = '-'; + node('.count').textContent = '-'; + node('.countVariance').textContent = '-'; + node('.timeImpact').textContent = '-'; + node('.timePercentImpact').textContent = '-'; } else { - node('.version').innerHTML = entry.page.version.name; - node('.time').innerHTML = ms(entry._time, false); - node('.timeVariance').innerHTML + node('.version').textContent = entry.page.version.name; + node('.time').textContent = ms(entry._time, false); + node('.timeVariance').textContent = percent(entry.timeVariancePercent, false); - node('.percent').innerHTML = percent(entry.timePercent, false); - node('.percentPerEntry').innerHTML + node('.percent').textContent = percent(entry.timePercent, false); + node('.percentPerEntry').textContent = percent(entry.timePercentPerEntry, false); - node('.percentVariance').innerHTML + node('.percentVariance').textContent = percent(entry.timePercentVariancePercent, false); - node('.count').innerHTML = count(entry._count, false); - node('.countVariance').innerHTML + node('.count').textContent = count(entry._count, false); + node('.countVariance').textContent = percent(entry.timeVariancePercent, false); - node('.timeImpact').innerHTML + node('.timeImpact').textContent = ms(entry.getTimeImpact(false), false); - node('.timePercentImpact').innerHTML + node('.timePercentImpact').textContent = percent(entry.getTimeImpactVariancePercent(false), false); } } @@ -927,7 +931,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. function addCodeSearchButton(entry, node) { if (entry.isGroup) return; var button = document.createElement("div"); - button.innerHTML = '?' + button.textContent = '?' button.className = "codeSearch" button.addEventListener('click', handleCodeSearch); node.appendChild(button); @@ -936,7 +940,11 @@ code is governed by a BSD-style license that can be found in the LICENSE file. function td(tr, content, className) { var td = document.createElement("td"); - td.innerHTML = content; + if (content[0] == '<') { + td.innerHTML = content; + } else { + td.textContent = content; + } td.className = className tr.appendChild(td); return td @@ -1002,7 +1010,25 @@ code is governed by a BSD-style license that can be found in the LICENSE file. // ========================================================================= // EventHandlers function handleBodyLoad() { - $('uploadInput').focus(); + $('uploadInput').focus(); + if (defaultData) { + handleLoadJSON(defaultData); + } else if (window.location.protocol !== 'file:') { + tryLoadDefaultResults(); + } + } + + function tryLoadDefaultResults() { + // Try to load a results.json file adjacent to this day. + var xhr = new XMLHttpRequest(); + // The markers on the following line can be used to replace the url easily + // with scripts. + xhr.open('GET', /*results-url-start*/'results.json'/*results-url-end*/, true); + xhr.onreadystatechange = function(e) { + if(this.readyState !== XMLHttpRequest.DONE || this.status !== 200) return; + handleLoadText(this.responseText); + }; + xhr.send(); } function handleLoadFile() { @@ -1011,14 +1037,23 @@ code is governed by a BSD-style license that can be found in the LICENSE file. var reader = new FileReader(); reader.onload = function(evt) { - pages = new Pages(); - versions = Versions.fromJSON(JSON.parse(this.result)); - initialize() - showPage(versions.versions[0].pages[0]); + handleLoadText(this.result); } reader.readAsText(file); } + function handleLoadText(text) { + handleLoadJSON(JSON.parse(text)); + } + + function handleLoadJSON(json) { + pages = new Pages(); + versions = Versions.fromJSON(json); + initialize() + showPage(versions.versions[0].pages[0]); + selectEntry(selectedPage.total); + } + function handleToggleGroup(event) { var group = event.target.parentNode.parentNode.entry; toggleGroup(selectedPage.get(group.name)); @@ -1097,7 +1132,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. showPopover(entry); } - function handleToggleVersionEnable(event) { + function handleToggleVersionOrPageEnable(event) { var item = this.item ; if (item === undefined) return; item .enabled = this.checked; @@ -1106,6 +1141,9 @@ code is governed by a BSD-style license that can be found in the LICENSE file. if (page === undefined || !page.version.enabled) { page = versions.getEnabledPage(page.name); } + if (!page.enabled) { + page = page.getNextPage(); + } showPage(page); } @@ -1190,13 +1228,17 @@ code is governed by a BSD-style license that can be found in the LICENSE file. } return -1; } + getNextPage(page) { + if (this.length == 0) return undefined; + return this.pages[(this.indexOf(page.name) + 1) % this.length]; + } get(name) { var index = this.indexOf(name); if (0 <= index) return this.pages[index]; return undefined } get length() { - return this.versions.length + return this.pages.length } getEntry(entry) { if (entry === undefined) return undefined; @@ -1315,21 +1357,20 @@ code is governed by a BSD-style license that can be found in the LICENSE file. constructor(version, page) { this.page = page; this.page.add(this); - this.total = new GroupedEntry('Total', /.*Total.*/, '#BBB'); + this.total = Group.groups.get('total').entry(); this.total.isTotal = true; - this.unclassified = new UnclassifiedEntry(this, "#000") + this.unclassified = new UnclassifiedEntry(this) this.groups = [ this.total, - new GroupedEntry('IC', /.*IC.*/, "#3366CC"), - new GroupedEntry('Optimize', - /StackGuard|.*Optimize.*|.*Deoptimize.*|Recompile.*/, "#DC3912"), - new GroupedEntry('Compile', /.*Compile.*/, "#FFAA00"), - new GroupedEntry('Parse', /.*Parse.*/, "#FF6600"), - new GroupedEntry('Callback', /.*Callback$/, "#109618"), - new GroupedEntry('API', /.*API.*/, "#990099"), - new GroupedEntry('GC', /GC|AllocateInTargetSpace/, "#0099C6"), - new GroupedEntry('JavaScript', /JS_Execution/, "#DD4477"), - new GroupedEntry('Runtime', /.*/, "#88BB00"), + Group.groups.get('ic').entry(), + Group.groups.get('optimize').entry(), + Group.groups.get('compile').entry(), + Group.groups.get('parse').entry(), + Group.groups.get('callback').entry(), + Group.groups.get('api').entry(), + Group.groups.get('gc').entry(), + Group.groups.get('javascript').entry(), + Group.groups.get('runtime').entry(), this.unclassified ]; this.entryDict = new Map(); @@ -1400,6 +1441,9 @@ code is governed by a BSD-style license that can be found in the LICENSE file. }); return sum; } + getNextPage() { + return this.version.getNextPage(this); + } } PageVersion.fromJSON = function(version, name, data) { var page = new PageVersion(version, pages.get(name)); @@ -1496,16 +1540,43 @@ code is governed by a BSD-style license that can be found in the LICENSE file. return new Entry(position, ...data); } - - class GroupedEntry extends Entry { + class Group { constructor(name, regexp, color) { - super(0, 'Group-' + name, 0, 0, 0, 0, 0, 0); + this.name = name; this.regexp = regexp; this.color = color; + this.enabled = true; + } + entry() { return new GroupedEntry(this) }; + } + Group.groups = new Map(); + Group.add = function(name, group) { + this.groups.set(name, group); + } + Group.add('total', new Group('Total', /.*Total.*/, '#BBB')); + Group.add('ic', new Group('IC', /.*IC.*/, "#3366CC")); + Group.add('optimize', new Group('Optimize', + /StackGuard|.*Optimize.*|.*Deoptimize.*|Recompile.*/, "#DC3912")); + Group.add('compile', new Group('Compile', /.*Compile.*/, "#FFAA00")); + Group.add('parse', new Group('Parse', /.*Parse.*/, "#FF6600")); + Group.add('callback', new Group('Callback', /.*Callback$/, "#109618")); + Group.add('api', new Group('API', /.*API.*/, "#990099")); + Group.add('gc', new Group('GC', /GC|AllocateInTargetSpace/, "#0099C6")); + Group.add('javascript', new Group('JavaScript', /JS_Execution/, "#DD4477")); + Group.add('runtime', new Group('Runtime', /.*/, "#88BB00")); + Group.add('unclassified', new Group('Unclassified', /.*/, "#000")); + + class GroupedEntry extends Entry { + constructor(group) { + super(0, 'Group-' + group.name, 0, 0, 0, 0, 0, 0); + this.group = group; this.entries = []; } + get regexp() { return this.group.regexp } + get color() { return this.group.color } + get enabled() { return this.group.enabled } add(entry) { - if (!entry.name.match(this.regexp)) return false; + if (!this.regexp.test(entry.name)) return false; this._time += entry.time; this._count += entry.count; // TODO: sum up variance @@ -1567,8 +1638,8 @@ code is governed by a BSD-style license that can be found in the LICENSE file. } class UnclassifiedEntry extends GroupedEntry { - constructor(page, color) { - super('Unclassified', undefined, color); + constructor(page) { + super(Group.groups.get('unclassified')); this.page = page; this._time = undefined; this._count = undefined; @@ -1630,14 +1701,21 @@ code is governed by a BSD-style license that can be found in the LICENSE file. </div> <div id="versionSelector" class="inline toggleContentVisibility"> - <h2>Version Selector</h2> + <h2>Versions</h2> <div class="content hidden"> <ul></ul> </div> </div> <div id="pageSelector" class="inline toggleContentVisibility"> - <h2>Page Selector</h2> + <h2>Pages</h2> + <div class="content hidden"> + <ul></ul> + </div> + </div> + + <div id="groupSelector" class="inline toggleContentVisibility"> + <h2>Groups</h2> <div class="content hidden"> <ul></ul> </div> |