Skip to content

Commit 4f941f2

Browse files
(added) allComponentRtids array holds rtids of last snapshot
1 parent c1c8698 commit 4f941f2

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/app/components/PerformanceVisx.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,22 @@ const tooltipStyles = {
6666

6767
/* DATA HANDLING HELPER FUNCTIONS */
6868

69-
// traverses a snapshot - returns object of rendering times OR component state types. Depends on 2nd arg
70-
69+
// traverses a snapshot for data: rendering time, component type, or rtid
7170
const traverse = (snapshot, fetchData, data = {}) => {
7271
if (!snapshot.children[0]) return;
7372
snapshot.children.forEach((child, idx) => {
7473
const componentName = child.name + -[idx + 1];
7574
// Get component Type
76-
if (fetchData === 'componentType') {
75+
if (fetchData === 'getComponentType') {
7776
if (child.state !== 'stateless') data[componentName] = 'STATEFUL';
7877
else data[componentName] = child.state;
7978
}
8079
// Get component Rendering Time
81-
else if (fetchData === 'renderTime') {
80+
else if (fetchData === 'getRenderTime') {
8281
const renderTime = Number(Number.parseFloat(child.componentData.actualDuration).toPrecision(5));
8382
data[componentName] = renderTime;
8483
}
85-
else if (fetchData === 'rtid') {
84+
else if (fetchData === 'getRtid') {
8685
data[componentName] = child.rtid;
8786
}
8887
traverse(snapshot.children[idx], fetchData, data);
@@ -103,7 +102,7 @@ const getSnapshotIds = (obj, snapshotIds = []) => {
103102
// Returns array of snapshot objs each with components and corresponding render times
104103
const getPerfMetrics = (snapshots, snapshotsIds):any[] => {
105104
return snapshots.reduce((perfSnapshots, curSnapshot, idx) => {
106-
return perfSnapshots.concat(traverse(curSnapshot, 'renderTime', { snapshotId: snapshotsIds[idx] }));
105+
return perfSnapshots.concat(traverse(curSnapshot, 'getRenderTime', { snapshotId: snapshotsIds[idx] }));
107106
}, []);
108107
};
109108

@@ -123,12 +122,10 @@ const PerformanceVisx = (props: BarStackProps) => {
123122
const { containerRef, TooltipInPortal } = useTooltipInPortal();
124123

125124
// filter and structure incoming data for VISX
126-
127125
const data = getPerfMetrics(snapshots, getSnapshotIds(hierarchy));
128-
129126
const keys = Object.keys(data[0]).filter(d => d !== 'snapshotId');
130-
131127
const allComponentStates = traverse(snapshots[0]);
128+
const allComponentRtids = traverse(snapshots[-1], 'getRtids');
132129

133130
// create array of total render times for each snapshot
134131
const totalRenderArr = data.reduce((totalRender, curSnapshot) => {

0 commit comments

Comments
 (0)