Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: tools/profview/profile-utils.js

Issue 2737083003: [tools/profview] Add individual function timeline view (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/profview/index.html ('k') | tools/profview/profview.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/profview/profile-utils.js
diff --git a/tools/profview/profile-utils.js b/tools/profview/profile-utils.js
index 9309d1dced244814507b08083b2b1995f2e897ac..a554488ce729db54a6db5d8ba8d1bb136aece7b9 100644
--- a/tools/profview/profile-utils.js
+++ b/tools/profview/profile-utils.js
@@ -72,10 +72,10 @@ function resolveCodeKindAndVmState(code, vmState) {
return kind;
}
-function createNodeFromStackEntry(code) {
+function createNodeFromStackEntry(code, codeId) {
let name = code ? code.name : "UNKNOWN";
- return { name, type : resolveCodeKind(code),
+ return { name, codeId, type : resolveCodeKind(code),
children : [], ownTicks : 0, ticks : 0 };
}
@@ -143,7 +143,7 @@ function addOrUpdateChildNode(parent, file, stackIndex, stackPos, ascending) {
let childId = childIdFromCode(codeId, code);
let child = parent.children[childId];
if (!child) {
- child = createNodeFromStackEntry(code);
+ child = createNodeFromStackEntry(code, codeId);
child.delayedExpansion = { frameList : [], ascending };
parent.children[childId] = child;
}
@@ -177,6 +177,7 @@ function expandTreeNode(file, node, filter) {
function createEmptyNode(name) {
return {
name : name,
+ codeId: -1,
type : "CAT",
children : [],
ownTicks : 0,
@@ -265,7 +266,7 @@ class FunctionListTree {
this.tree = root;
this.categories = categories;
} else {
- this.tree = { name : "root", children : [], ownTicks : 0, ticks : 0 };
+ this.tree = { name : "root", codeId: -1, children : [], ownTicks : 0, ticks : 0 };
Jarin 2017/03/08 14:25:56 <80 character lines, please (here and below).
Leszek Swirski 2017/03/08 14:32:40 Done.
this.categories = null;
}
@@ -299,7 +300,7 @@ class FunctionListTree {
}
child = tree.children[childId];
if (!child) {
- child = createNodeFromStackEntry(code);
+ child = createNodeFromStackEntry(code, codeId);
child.children[0] = createEmptyNode("Top-down tree");
child.children[0].delayedExpansion =
{ frameList : [], ascending : false };
@@ -367,6 +368,49 @@ class CategorySampler {
}
}
+class FunctionTimelineProcessor {
+ constructor(functionCodeId, filter) {
+ this.functionCodeId = functionCodeId;
+ this.filter = filter;
+ this.blocks = [];
+ this.currentBlock = null;
+ }
+
+ addStack(file, tickIndex) {
+ let { tm : timestamp, vm : vmState, s : stack } = file.ticks[tickIndex];
+
+ let codeInStack = stack.includes(this.functionCodeId);
+ if (codeInStack) {
+ let topOfStack = -1;
+ for (let i = 0; i < stack.length - 1; i += 2) {
+ let codeId = stack[i];
+ let code = codeId >= 0 ? file.code[codeId] : undefined;
+ let type = code ? code.type : undefined;
+ let kind = code ? code.kind : undefined;
+ if (!this.filter(type, kind)) continue;
+
+ topOfStack = i;
+ break;
+ }
+
+ let codeIsTopOfStack = (topOfStack !== -1 && stack[topOfStack] === this.functionCodeId);
+
+ if (this.currentBlock !== null) {
+ this.currentBlock.end = timestamp;
+
+ if (codeIsTopOfStack === this.currentBlock.topOfStack) {
+ return;
+ }
+ }
+
+ this.currentBlock = { start: timestamp, end: timestamp, topOfStack: codeIsTopOfStack };
+ this.blocks.push(this.currentBlock);
+ } else {
+ this.currentBlock = null;
+ }
+ }
+}
+
// Generates a tree out of a ticks sequence.
// {file} is the JSON files with the ticks and code objects.
// {startTime}, {endTime} is the interval.
« no previous file with comments | « tools/profview/index.html ('k') | tools/profview/profview.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698