Commit 817d5c43 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[tools] Support loading raw runtime call stats output in callstat.html

This enables comparing single runs from the direct command line ouptut
generated by --runtime-call-stats

No-Try: true
No-Presubmit: true
Change-Id: Ieac06bbd95c2a73f8064af161fe35f6fb083648f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2170093
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67432}
parent bef5b85d
...@@ -1107,7 +1107,15 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1107,7 +1107,15 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
} }
function handleLoadText(text, append, fileName) { function handleLoadText(text, append, fileName) {
handleLoadJSON(JSON.parse(text), append, fileName); try {
handleLoadJSON(JSON.parse(text), append, fileName);
} catch(e) {
if (!fileName.endsWith('.txt')) {
alert(`Error parsing "${fileName}"`);
console.error(e);
}
handleLoadTXT(text, append, fileName);
}
} }
function getStateFromParams() { function getStateFromParams() {
...@@ -1128,17 +1136,37 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1128,17 +1136,37 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
if (append && !isFirstLoad) { if (append && !isFirstLoad) {
json = createUniqueVersions(json) json = createUniqueVersions(json)
} }
var state = getStateFromParams();
if (!append || isFirstLoad) { if (!append || isFirstLoad) {
pages = new Pages(); pages = new Pages();
versions = Versions.fromJSON(json); versions = Versions.fromJSON(json);
} else { } else {
Versions.fromJSON(json).forEach(e => versions.add(e)) Versions.fromJSON(json).forEach(e => versions.add(e))
} }
displayResultsAfterLoading(isFirstLoad)
}
function handleLoadTXT(txt, append, fileName) {
let isFirstLoad = pages === undefined;
// Load raw RCS output which contains a single page
if (!append || isFirstLoad) {
pages = new Pages();
versions = new Versions()
}
versions.add(Version.fromTXT(fileName, txt))
displayResultsAfterLoading()
}
function displayResultsAfterLoading(isFirstLoad) {
let state = getStateFromParams();
initialize() initialize()
if (isFirstLoad && !popHistoryState(state)) { if (isFirstLoad && !popHistoryState(state)) {
showEntry(selectedPage.total); showEntry(selectedPage.total);
return;
} }
selectedPage = versions.versions[0].pages[0]
if (selectedPage == undefined) return;
showPage(selectedPage);
} }
function fixClusterTelemetryResults(json) { function fixClusterTelemetryResults(json) {
...@@ -1358,14 +1386,15 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1358,14 +1386,15 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
if (page !== undefined) return page; if (page !== undefined) return page;
} }
} }
}
Versions.fromJSON = function(json) { static fromJSON(json) {
var versions = new Versions(); var versions = new Versions();
for (var version in json) { for (var version in json) {
versions.add(Version.fromJSON(version, json[version])); versions.add(Version.fromJSON(version, json[version]));
}
versions.sort();
return versions;
} }
versions.sort();
return versions;
} }
class Version { class Version {
...@@ -1475,14 +1504,22 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1475,14 +1504,22 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
sort() { sort() {
this.pages.sort(NameComparator) this.pages.sort(NameComparator)
} }
}
Version.fromJSON = function(name, data) { static fromJSON(name, data) {
var version = new Version(name); var version = new Version(name);
for (var pageName in data) { for (var pageName in data) {
version.add(PageVersion.fromJSON(version, pageName, data[pageName])); version.add(PageVersion.fromJSON(version, pageName, data[pageName]));
}
version.sort();
return version;
}
static fromTXT(name, txt) {
let version = new Version(name);
let pageName = "RAW DATA";
version.add(PageVersion.fromTXT(version, pageName, txt));
return version;
} }
version.sort();
return version;
} }
class Pages extends Map { class Pages extends Map {
...@@ -1610,24 +1647,39 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1610,24 +1647,39 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
getNextPage() { getNextPage() {
return this.version.getNextPage(this); return this.version.getNextPage(this);
} }
}
PageVersion.fromJSON = function(version, name, data) { static fromJSON(version, name, data) {
let page = new PageVersion(version, pages.get(name)); let page = new PageVersion(version, pages.get(name));
// Distinguish between the legacy format which just uses Arrays, // Distinguish between the legacy format which just uses Arrays,
// or the new object style. // or the new object style.
if (Array.isArray(data)) { if (Array.isArray(data)) {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
page.add(Entry.fromLegacyJSON(i, data[data.length - i - 1])); page.add(Entry.fromLegacyJSON(i, data[data.length - i - 1]));
}
} else {
let position = 0;
for (let metric_name in data) {
page.add(Entry.fromJSON(position, metric_name, data[metric_name]));
position++;
}
} }
} else { page.sort();
let position = 0; return page
for (let metric_name in data) { }
page.add(Entry.fromJSON(position, metric_name, data[metric_name]));
position++; static fromTXT(version, name, txt) {
let pageVersion = new PageVersion(version, pages.get(name));
let lines = txt.split('\n');
let split = / +/g
// Skip the first two lines (HEADER and SEPARATOR)
for (let i = 2; i < lines.length; i++) {
let line = lines[i].trim().split(split)
if (line.length != 5) continue;
let position = i-2;
pageVersion.add(Entry.fromTXT(position, line));
} }
return pageVersion;
} }
page.sort();
return page
} }
...@@ -1716,15 +1768,27 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1716,15 +1768,27 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
get timeVariancePercent() { get timeVariancePercent() {
return this._timeVariancePercent return this._timeVariancePercent
} }
}
Entry.fromLegacyJSON = function(position, data) { static fromLegacyJSON(position, data) {
return new Entry(position, ...data); return new Entry(position, ...data);
} }
Entry.fromJSON = function(position, name, data) {
let time = data.duration; static fromJSON(position, name, data) {
let count = data.count; let time = data.duration;
return new Entry(position, name, time.average, time.stddev, let count = data.count;
count.average, count.stddev); return new Entry(position, name, time.average, time.stddev, 0,
count.average, count.stddev, 0);
}
static fromTXT(position, splitLine) {
let [name, time, timePercent, count, countPercent] = splitLine;
time = time.split('ms')
let timeDeviation = 0, countDeviation = 0;
let timeDeviationPercent = 0, countDeviationPercent = 0
return new Entry(position, name,
Number.parseFloat(time), timeDeviation, timeDeviationPercent,
Number.parseInt(count), countDeviation, countDeviationPercent)
}
} }
class Group { class Group {
...@@ -1899,11 +1963,11 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1899,11 +1963,11 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
<form name="fileForm"> <form name="fileForm">
<p> <p>
<label for="uploadInput">Load File:</label> <label for="uploadInput">Load File:</label>
<input id="uploadInput" type="file" name="files" onchange="handleLoadFile();" accept=".json"> <input id="uploadInput" type="file" name="files" onchange="handleLoadFile();" accept=".json,.txt">
</p> </p>
<p> <p>
<label for="appendInput">Append File:</label> <label for="appendInput">Append File:</label>
<input id="appendInput" type="file" name="files" onchange="handleAppendFile();" accept=".json"> <input id="appendInput" type="file" name="files" onchange="handleAppendFile();" accept=".json,.txt">
</p> </p>
</form> </form>
</div> </div>
......
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