1
1
/* eslint-disable guard-for-in */
2
- /* eslint-disable no-restricted-syntax */
2
+ // * eslint-disable no-restricted-syntax */
3
3
// @ts -nocheck
4
4
import React , { useState } from 'react' ;
5
- import FormControlLabel from '@material-ui/core/FormControlLabel' ;
6
- import { ParentSize } from '@visx/responsive' ;
7
5
import {
8
6
MemoryRouter as Router ,
9
7
Route ,
10
8
NavLink ,
11
9
Switch ,
12
10
} from 'react-router-dom' ;
13
- import { Component } from 'react' ;
14
- import { render } from 'react-dom' ;
15
11
import RenderingFrequency from './RenderingFrequency' ;
16
12
// import Switch from '@material-ui/core/Switch';
17
13
import BarGraph from './BarGraph' ;
18
14
import BarGraphComparison from './BarGraphComparison' ;
19
15
import { useStoreContext } from '../store' ;
20
16
// import snapshots from './snapshots';
21
- import snapshots from './snapshots' ;
22
-
23
17
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
-
25
18
/* NOTES
26
19
Issue - Not fully compatible with recoil apps. Reference the recoil-todo-test.
27
20
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
30
23
to note - all snapshots do render (check HTML doc) within the chrome extension but they do
31
24
not display because height is not consistently passed to each bar. This side effect is only
32
25
seen in recoil apps...
33
- */
34
-
26
+ */
35
27
// typescript for PROPS from StateRoute.tsx
36
28
interface BarStackProps {
37
29
width : number ;
38
30
height : number ;
39
31
snapshots : [ ] ;
40
32
hierarchy : any ;
41
33
}
42
-
43
34
const makePropsPretty = data => {
44
35
const propsFormat = [ ] ;
45
36
const nestedObj = [ ] ;
@@ -61,7 +52,6 @@ const makePropsPretty = data => {
61
52
}
62
53
return propsFormat ;
63
54
} ;
64
-
65
55
const collectNodes = ( snaps , componentName ) => {
66
56
const componentsResult = [ ] ;
67
57
const renderResult = [ ] ;
@@ -110,7 +100,6 @@ const collectNodes = (snaps, componentName) => {
110
100
}
111
101
}
112
102
}
113
-
114
103
const finalResults = componentsResult . map ( ( e , index ) => {
115
104
const name = Object . keys ( e ) [ 0 ] ;
116
105
e [ name ] . rendertime = renderResult [ index ] ;
@@ -123,15 +112,12 @@ const collectNodes = (snaps, componentName) => {
123
112
}
124
113
return finalResults ;
125
114
} ;
126
-
127
115
/* DATA HANDLING HELPER FUNCTIONS */
128
116
const traverse = ( snapshot , data , snapshots , currTotalRender = 0 ) => {
129
117
if ( ! snapshot . children [ 0 ] ) return ;
130
-
131
118
// loop through snapshots
132
119
snapshot . children . forEach ( ( child , idx ) => {
133
120
const componentName = child . name + - [ idx + 1 ] ;
134
-
135
121
// Get component Rendering Time
136
122
const renderTime = Number (
137
123
Number . parseFloat ( child . componentData . actualDuration ) . toPrecision ( 5 ) ,
@@ -140,7 +126,6 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
140
126
currTotalRender += renderTime ;
141
127
// components as keys and set the value to their rendering time
142
128
data . barStack [ data . barStack . length - 1 ] [ componentName ] = renderTime ;
143
-
144
129
// Get component stateType
145
130
if ( ! data . componentData [ componentName ] ) {
146
131
data . componentData [ componentName ] = {
@@ -157,9 +142,7 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
157
142
data . componentData [ componentName ] . renderFrequency ++ ;
158
143
}
159
144
// else {
160
-
161
145
// }
162
-
163
146
// add to total render time
164
147
data . componentData [ componentName ] . totalRenderTime += renderTime ;
165
148
// Get rtid for the hovering feature
@@ -171,21 +154,17 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
171
154
data . maxTotalRender = Math . max ( currTotalRender , data . maxTotalRender ) ;
172
155
return data ;
173
156
} ;
174
-
175
157
// Retrieve snapshot series data from Chrome's local storage.
176
158
const allStorage = ( ) => {
177
159
const values = [ ] ;
178
160
const keys = Object . keys ( localStorage ) ;
179
161
let i = keys . length ;
180
-
181
-
182
162
while ( i -- ) {
183
163
const series = localStorage . getItem ( keys [ i ] ) ;
184
164
values . push ( JSON . parse ( series ) ) ;
185
165
}
186
166
return values ;
187
167
} ;
188
-
189
168
// Gets snapshot Ids for the regular bar graph view.
190
169
const getSnapshotIds = ( obj , snapshotIds = [ ] ) : string [ ] => {
191
170
snapshotIds . push ( `${ obj . name } .${ obj . branch } ` ) ;
@@ -196,7 +175,6 @@ const getSnapshotIds = (obj, snapshotIds = []): string[] => {
196
175
}
197
176
return snapshotIds ;
198
177
} ;
199
-
200
178
// Returns array of snapshot objs each with components and corresponding render times.
201
179
const getPerfMetrics = ( snapshots , snapshotsIds ) : { } => {
202
180
const perfData = {
@@ -210,7 +188,6 @@ const getPerfMetrics = (snapshots, snapshotsIds): {} => {
210
188
} ) ;
211
189
return perfData ;
212
190
} ;
213
-
214
191
/* EXPORT COMPONENT */
215
192
const PerformanceVisx = ( props : BarStackProps ) => {
216
193
// hook used to dispatch onhover action in rect
@@ -223,7 +200,6 @@ const PerformanceVisx = (props: BarStackProps) => {
223
200
const [ comparisonData , setComparisonData ] = useState ( ) ;
224
201
const NO_STATE_MSG = 'No state change detected. Trigger an event to change state' ;
225
202
const data = getPerfMetrics ( snapshots , getSnapshotIds ( hierarchy ) ) ;
226
-
227
203
const renderComparisonBargraph = ( ) => {
228
204
if ( hierarchy ) {
229
205
return (
@@ -236,20 +212,17 @@ const PerformanceVisx = (props: BarStackProps) => {
236
212
) ;
237
213
}
238
214
} ;
239
-
240
215
const renderBargraph = ( ) => {
241
216
if ( hierarchy ) {
242
217
return < BarGraph data = { data } width = { width } height = { height } /> ;
243
218
}
244
219
} ;
245
-
246
220
const renderComponentDetailsView = ( ) => {
247
221
if ( hierarchy ) {
248
222
return < RenderingFrequency data = { data . componentData } /> ;
249
223
}
250
224
return < div className = "noState" > { NO_STATE_MSG } </ div > ;
251
225
} ;
252
-
253
226
return (
254
227
< Router >
255
228
< div className = "performance-nav-bar-container" >
@@ -279,7 +252,6 @@ const PerformanceVisx = (props: BarStackProps) => {
279
252
Component Details
280
253
</ NavLink >
281
254
</ div >
282
-
283
255
< Switch >
284
256
< Route path = "/comparison" render = { renderComparisonBargraph } />
285
257
< Route path = "/componentdetails" render = { renderComponentDetailsView } />
@@ -288,5 +260,4 @@ const PerformanceVisx = (props: BarStackProps) => {
288
260
</ Router >
289
261
) ;
290
262
} ;
291
-
292
- export default PerformanceVisx ;
263
+ export default PerformanceVisx ;
0 commit comments