Skip to content

Commit 36c3823

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Speed up batch key lookup in flame graph
This shaves a few ms off the flame graph draw function, more noticeable for larger traces. Bug: 40278532 Change-Id: I5adf9f01b339007ee4e36f6118924ddd75219edf Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6221818 Auto-Submit: Connor Clark <[email protected]> Reviewed-by: Paul Irish <[email protected]> Commit-Queue: Connor Clark <[email protected]>
1 parent 3a0ded1 commit 36c3823

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

front_end/ui/legacy/components/perf_ui/FlameChart.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,16 +2550,17 @@ export class FlameChart extends Common.ObjectWrapper.eventMixin<EventTypes, type
25502550
color: string;
25512551
outline: boolean;
25522552
}
2553-
const keys: BatchKey[] = [];
2553+
const keysByColorWithOutline = new Map<string, BatchKey>();
2554+
const keysByColorWithNoOutline = new Map<string, BatchKey>();
25542555
const getOrMakeKey = (color: string, outline: boolean): BatchKey => {
2555-
for (const key of keys) {
2556-
if (key.outline === outline && key.color === color) {
2557-
return key;
2558-
}
2556+
const map = outline ? keysByColorWithOutline : keysByColorWithNoOutline;
2557+
const key = map.get(color);
2558+
if (key) {
2559+
return key;
25592560
}
25602561

25612562
const newKey = {color, outline};
2562-
keys.push(newKey);
2563+
map.set(color, newKey);
25632564
return newKey;
25642565
};
25652566

0 commit comments

Comments
 (0)