Skip to content

Commit da04dc6

Browse files
committed
Fixed breakage on save series & component details
1 parent bf5bb9d commit da04dc6

File tree

2 files changed

+27
-109
lines changed

2 files changed

+27
-109
lines changed

src/app/components/PerformanceVisx.tsx

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
/* eslint-disable guard-for-in */
2-
/* eslint-disable no-restricted-syntax */
2+
//* eslint-disable no-restricted-syntax */
33
// @ts-nocheck
44
import React, { useState } from 'react';
5-
import FormControlLabel from '@material-ui/core/FormControlLabel';
6-
import { ParentSize } from '@visx/responsive';
75
import {
86
MemoryRouter as Router,
97
Route,
108
NavLink,
119
Switch,
1210
} from 'react-router-dom';
13-
import { Component } from 'react';
14-
import { render } from 'react-dom';
1511
import RenderingFrequency from './RenderingFrequency';
1612
// import Switch from '@material-ui/core/Switch';
1713
import BarGraph from './BarGraph';
1814
import BarGraphComparison from './BarGraphComparison';
1915
import { useStoreContext } from '../store';
2016
// import snapshots from './snapshots';
21-
import snapshots from './snapshots';
22-
2317
const exclude = ['childExpirationTime', 'staticContext', '_debugSource', 'actualDuration', 'actualStartTime', 'treeBaseDuration', '_debugID', '_debugIsCurrentlyTiming', 'selfBaseDuration', 'expirationTime', 'effectTag', 'alternate', '_owner', '_store', 'get key', 'ref', '_self', '_source', 'firstBaseUpdate', 'updateQueue', 'lastBaseUpdate', 'shared', 'responders', 'pending', 'lanes', 'childLanes', 'effects', 'memoizedState', 'pendingProps', 'lastEffect', 'firstEffect', 'tag', 'baseState', 'baseQueue', 'dependencies', 'Consumer', 'context', '_currentRenderer', '_currentRenderer2', 'mode', 'flags', 'nextEffect', 'sibling', 'create', 'deps', 'next', 'destroy', 'parentSub', 'child', 'key', 'return', 'children', '$$typeof', '_threadCount', '_calculateChangedBits', '_currentValue', '_currentValue2', 'Provider', '_context', 'stateNode', 'elementType', 'type'];
24-
2518
/* NOTES
2619
Issue - Not fully compatible with recoil apps. Reference the recoil-todo-test.
2720
Barstacks display inconsistently...however, almost always displays upon initial test app load or
@@ -30,16 +23,14 @@ However, cycling between updating state and then emptying sometimes fixes the st
3023
to note - all snapshots do render (check HTML doc) within the chrome extension but they do
3124
not display because height is not consistently passed to each bar. This side effect is only
3225
seen in recoil apps...
33-
*/
34-
26+
*/
3527
// typescript for PROPS from StateRoute.tsx
3628
interface BarStackProps {
3729
width: number;
3830
height: number;
3931
snapshots: [];
4032
hierarchy: any;
4133
}
42-
4334
const makePropsPretty = data => {
4435
const propsFormat = [];
4536
const nestedObj = [];
@@ -61,7 +52,6 @@ const makePropsPretty = data => {
6152
}
6253
return propsFormat;
6354
};
64-
6555
const collectNodes = (snaps, componentName) => {
6656
const componentsResult = [];
6757
const renderResult = [];
@@ -110,7 +100,6 @@ const collectNodes = (snaps, componentName) => {
110100
}
111101
}
112102
}
113-
114103
const finalResults = componentsResult.map((e, index) => {
115104
const name = Object.keys(e)[0];
116105
e[name].rendertime = renderResult[index];
@@ -123,15 +112,12 @@ const collectNodes = (snaps, componentName) => {
123112
}
124113
return finalResults;
125114
};
126-
127115
/* DATA HANDLING HELPER FUNCTIONS */
128116
const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
129117
if (!snapshot.children[0]) return;
130-
131118
// loop through snapshots
132119
snapshot.children.forEach((child, idx) => {
133120
const componentName = child.name + -[idx + 1];
134-
135121
// Get component Rendering Time
136122
const renderTime = Number(
137123
Number.parseFloat(child.componentData.actualDuration).toPrecision(5),
@@ -140,7 +126,6 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
140126
currTotalRender += renderTime;
141127
// components as keys and set the value to their rendering time
142128
data.barStack[data.barStack.length - 1][componentName] = renderTime;
143-
144129
// Get component stateType
145130
if (!data.componentData[componentName]) {
146131
data.componentData[componentName] = {
@@ -157,9 +142,7 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
157142
data.componentData[componentName].renderFrequency++;
158143
}
159144
// else {
160-
161145
// }
162-
163146
// add to total render time
164147
data.componentData[componentName].totalRenderTime += renderTime;
165148
// Get rtid for the hovering feature
@@ -171,21 +154,17 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
171154
data.maxTotalRender = Math.max(currTotalRender, data.maxTotalRender);
172155
return data;
173156
};
174-
175157
// Retrieve snapshot series data from Chrome's local storage.
176158
const allStorage = () => {
177159
const values = [];
178160
const keys = Object.keys(localStorage);
179161
let i = keys.length;
180-
181-
182162
while (i--) {
183163
const series = localStorage.getItem(keys[i]);
184164
values.push(JSON.parse(series));
185165
}
186166
return values;
187167
};
188-
189168
// Gets snapshot Ids for the regular bar graph view.
190169
const getSnapshotIds = (obj, snapshotIds = []): string[] => {
191170
snapshotIds.push(`${obj.name}.${obj.branch}`);
@@ -196,7 +175,6 @@ const getSnapshotIds = (obj, snapshotIds = []): string[] => {
196175
}
197176
return snapshotIds;
198177
};
199-
200178
// Returns array of snapshot objs each with components and corresponding render times.
201179
const getPerfMetrics = (snapshots, snapshotsIds): {} => {
202180
const perfData = {
@@ -210,7 +188,6 @@ const getPerfMetrics = (snapshots, snapshotsIds): {} => {
210188
});
211189
return perfData;
212190
};
213-
214191
/* EXPORT COMPONENT */
215192
const PerformanceVisx = (props: BarStackProps) => {
216193
// hook used to dispatch onhover action in rect
@@ -223,7 +200,6 @@ const PerformanceVisx = (props: BarStackProps) => {
223200
const [comparisonData, setComparisonData] = useState();
224201
const NO_STATE_MSG = 'No state change detected. Trigger an event to change state';
225202
const data = getPerfMetrics(snapshots, getSnapshotIds(hierarchy));
226-
227203
const renderComparisonBargraph = () => {
228204
if (hierarchy) {
229205
return (
@@ -236,20 +212,17 @@ const PerformanceVisx = (props: BarStackProps) => {
236212
);
237213
}
238214
};
239-
240215
const renderBargraph = () => {
241216
if (hierarchy) {
242217
return <BarGraph data={data} width={width} height={height} />;
243218
}
244219
};
245-
246220
const renderComponentDetailsView = () => {
247221
if (hierarchy) {
248222
return <RenderingFrequency data={data.componentData} />;
249223
}
250224
return <div className="noState">{NO_STATE_MSG}</div>;
251225
};
252-
253226
return (
254227
<Router>
255228
<div className="performance-nav-bar-container">
@@ -279,7 +252,6 @@ const PerformanceVisx = (props: BarStackProps) => {
279252
Component Details
280253
</NavLink>
281254
</div>
282-
283255
<Switch>
284256
<Route path="/comparison" render={renderComparisonBargraph} />
285257
<Route path="/componentdetails" render={renderComponentDetailsView} />
@@ -288,5 +260,4 @@ const PerformanceVisx = (props: BarStackProps) => {
288260
</Router>
289261
);
290262
};
291-
292-
export default PerformanceVisx;
263+
export default PerformanceVisx;
Lines changed: 24 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,59 @@
1-
/* eslint-disable jsx-a11y/click-events-have-key-events */
2-
/* eslint-disable jsx-a11y/no-static-element-interactions */
3-
/* eslint-disable react/prop-types */
4-
import React, { useState } from 'react';
5-
import { render } from 'react-dom';
1+
import React from 'react';
62
import { onHover, onHoverExit } from '../actions/actions';
73
import { useStoreContext } from '../store';
84

9-
const RenderingFrequency = props => {
5+
const RenderingFrequency = (props) => {
106
const perfData = props.data;
117
return (
128
<div>
13-
{Object.keys(perfData).map(componentName => {
9+
{Object.keys(perfData).map((componentName) => {
1410
const currentComponent = perfData[componentName];
1511
return (
1612
<ComponentCard
1713
componentName={componentName}
1814
stateType={currentComponent.stateType}
1915
averageRenderTime={(
20-
currentComponent.totalRenderTime
21-
/ currentComponent.renderFrequency
16+
currentComponent.totalRenderTime /
17+
currentComponent.renderFrequency
2218
).toFixed(3)}
2319
renderFrequency={currentComponent.renderFrequency}
2420
rtid={currentComponent.rtid}
25-
information={perfData[componentName].information}
2621
/>
2722
);
2823
})}
2924
</div>
3025
);
3126
};
32-
33-
const ComponentCard = props => {
27+
const ComponentCard = (props) => {
3428
const {
3529
componentName,
3630
stateType,
3731
averageRenderTime,
3832
renderFrequency,
3933
rtid,
40-
information,
4134
} = props;
4235
const [{ tabs, currentTab }, dispatch] = useStoreContext();
43-
const [expand, setExpand] = useState(false);
44-
45-
// render time for each component from each snapshot
46-
// differences in state change that happened prior;
47-
48-
const dataComponentArray = [];
49-
for (let i = 0; i < information.length; i++) {
50-
dataComponentArray.push(<DataComponent header={Object.keys(information[i])} paragraphs={Object.values(information[i])} />);
51-
}
52-
36+
const onMouseMove = () => {
37+
dispatch(onHover(rtid));
38+
};
39+
const onMouseLeave = () => {
40+
dispatch(onHoverExit(rtid));
41+
};
5342
return (
54-
<div className="borderStyling">
55-
<div
56-
className={expand ? 'ExpandStyledGridElement' : 'StyledGridElement'}
57-
>
58-
<div className="RenderLeft">
59-
<h3>
60-
{componentName}
61-
{' '}
62-
</h3>
63-
<h4>{stateType}</h4>
64-
<h4>
65-
average time:
66-
{' '}
67-
{averageRenderTime}
68-
{' '}
69-
ms
70-
</h4>
71-
</div>
72-
<div
73-
onClick={() => {
74-
if (expand === true) {
75-
setExpand(false);
76-
} else {
77-
setExpand(true);
78-
}
79-
}}
80-
className="RenderRight"
81-
>
82-
<p>{renderFrequency}</p>
83-
</div>
43+
<div
44+
onMouseLeave={onMouseLeave}
45+
onMouseMove={onMouseMove}
46+
className="StyledGridElement"
47+
>
48+
<div className="RenderLeft">
49+
<h3>{componentName} </h3>
50+
<h4>{stateType}</h4>
51+
<h4>average time: {averageRenderTime} ms</h4>
8452
</div>
85-
<div className={expand === true ? 'DataComponent' : null} >
86-
{expand === true ? dataComponentArray : null}
53+
<div className="RenderRight">
54+
<p>{renderFrequency}</p>
8755
</div>
8856
</div>
8957
);
9058
};
91-
92-
const DataComponent = props => {
93-
const {
94-
header,
95-
paragraphs,
96-
} = props;
97-
98-
return (
99-
<div className="borderCheck">
100-
<h4>
101-
{' '}
102-
{header}
103-
</h4>
104-
<p>
105-
106-
{paragraphs}
107-
</p>
108-
</div>
109-
);
110-
};
111-
112-
export default RenderingFrequency;
59+
export default RenderingFrequency;

0 commit comments

Comments
 (0)