Skip to content

Commit 9f08129

Browse files
committed
Split getSelfAndTotal.
When we add the function list, we'll want to be able to sort the table by either the self column or the total column. For that use case it makes sense to have separate methods to query these values. Functionally neutral change.
1 parent 4bd8b75 commit 9f08129

1 file changed

Lines changed: 26 additions & 15 deletions

File tree

src/profile-logic/call-tree.ts

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ interface CallTreeInternal {
105105
hasChildren(callNodeIndex: IndexIntoCallNodeTable): boolean;
106106
createChildren(nodeIndex: IndexIntoCallNodeTable): CallNodeChildren;
107107
createRoots(): CallNodeChildren;
108-
getSelfAndTotal(nodeIndex: IndexIntoCallNodeTable): SelfAndTotal;
108+
getSelf(nodeIndex: IndexIntoCallNodeTable): number;
109+
getTotal(nodeIndex: IndexIntoCallNodeTable): number;
109110
findHeaviestPathInSubtree(
110111
callNodeIndex: IndexIntoCallNodeTable
111112
): CallNodePath;
@@ -171,10 +172,12 @@ export class CallTreeInternalNonInverted implements CallTreeInternal {
171172
return this._callNodeHasChildren[callNodeIndex] !== 0;
172173
}
173174

174-
getSelfAndTotal(callNodeIndex: IndexIntoCallNodeTable): SelfAndTotal {
175-
const self = this._callTreeTimings.self[callNodeIndex];
176-
const total = this._callTreeTimings.total[callNodeIndex];
177-
return { self, total };
175+
getSelf(callNodeIndex: IndexIntoCallNodeTable): number {
176+
return this._callTreeTimings.self[callNodeIndex];
177+
}
178+
179+
getTotal(callNodeIndex: IndexIntoCallNodeTable): number {
180+
return this._callTreeTimings.total[callNodeIndex];
178181
}
179182

180183
findHeaviestPathInSubtree(
@@ -216,11 +219,12 @@ export class CallTreeInternalFunctionList implements CallTreeInternal {
216219
return this._timings.sortedFuncs;
217220
}
218221

219-
getSelfAndTotal(nodeIndex: IndexIntoCallNodeTable): SelfAndTotal {
220-
return {
221-
self: this._timings.funcSelf[nodeIndex],
222-
total: this._timings.funcTotal[nodeIndex],
223-
};
222+
getSelf(nodeIndex: IndexIntoCallNodeTable): number {
223+
return this._timings.funcSelf[nodeIndex];
224+
}
225+
226+
getTotal(nodeIndex: IndexIntoCallNodeTable): number {
227+
return this._timings.funcTotal[nodeIndex];
224228
}
225229

226230
findHeaviestPathInSubtree(
@@ -288,13 +292,19 @@ class CallTreeInternalInverted implements CallTreeInternal {
288292
return children;
289293
}
290294

291-
getSelfAndTotal(callNodeIndex: IndexIntoCallNodeTable): SelfAndTotal {
295+
getSelf(callNodeIndex: IndexIntoCallNodeTable): number {
296+
if (this._callNodeInfo.isRoot(callNodeIndex)) {
297+
return this._totalPerRootFunc[callNodeIndex];
298+
}
299+
return 0;
300+
}
301+
302+
getTotal(callNodeIndex: IndexIntoCallNodeTable): number {
292303
if (this._callNodeInfo.isRoot(callNodeIndex)) {
293-
const total = this._totalPerRootFunc[callNodeIndex];
294-
return { self: total, total };
304+
return this._totalPerRootFunc[callNodeIndex];
295305
}
296306
const { total } = this._getTotalAndHasChildren(callNodeIndex);
297-
return { self: 0, total };
307+
return total;
298308
}
299309

300310
_getTotalAndHasChildren(
@@ -445,7 +455,8 @@ export class CallTree {
445455
this._thread.funcTable.name[funcIndex]
446456
);
447457

448-
const { self, total } = this._internal.getSelfAndTotal(callNodeIndex);
458+
const total = this._internal.getTotal(callNodeIndex);
459+
const self = this._internal.getSelf(callNodeIndex);
449460
const totalRelative = total / this._rootTotalSummary;
450461
const selfRelative = self / this._rootTotalSummary;
451462

0 commit comments

Comments
 (0)