@@ -16,6 +16,7 @@ import BarGraphComparison from './BarGraphComparison';
16
16
import BarGraphComparisonActions from './BarGraphComparisonActions' ;
17
17
import { useStoreContext } from '../store' ;
18
18
import { setCurrentTabInApp } from '../actions/actions' ;
19
+
19
20
/* NOTES
20
21
Issue - Not fully compatible with recoil apps. Reference the recoil-todo-test.
21
22
Barstacks display inconsistently...however, almost always displays upon initial test app load or
@@ -39,10 +40,10 @@ const collectNodes = (snaps, componentName) => {
39
40
const renderResult = [ ] ;
40
41
let trackChanges = 0 ;
41
42
let newChange = true ;
42
- for ( let x = 0 ; x < snaps . length ; x ++ ) {
43
+ for ( let x = 0 ; x < snaps . length ; x += 1 ) {
43
44
const snapshotList = [ ] ;
44
45
snapshotList . push ( snaps [ x ] ) ;
45
- for ( let i = 0 ; i < snapshotList . length ; i ++ ) {
46
+ for ( let i = 0 ; i < snapshotList . length ; i += 1 ) {
46
47
const cur = snapshotList [ i ] ;
47
48
if ( cur . name === componentName ) {
48
49
const renderTime = Number (
@@ -118,7 +119,7 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
118
119
}
119
120
// increment render frequencies
120
121
if ( renderTime > 0 ) {
121
- data . componentData [ componentName ] . renderFrequency ++ ;
122
+ data . componentData [ componentName ] . renderFrequency += 1 ;
122
123
}
123
124
124
125
// add to total render time
@@ -159,7 +160,7 @@ const getPerfMetrics = (snapshots, snapshotsIds): {} => {
159
160
maxTotalRender : 0 ,
160
161
} ;
161
162
snapshots . forEach ( ( snapshot , i ) => {
162
- perfData . barStack . push ( { snapshotId : snapshotsIds [ i ] } ) ;
163
+ perfData . barStack . push ( { snapshotId : snapshotsIds [ i ] , route : snapshot . route . url } ) ;
163
164
traverse ( snapshot , perfData , snapshots ) ;
164
165
} ) ;
165
166
return perfData ;
@@ -177,6 +178,8 @@ const PerformanceVisx = (props: BarStackProps) => {
177
178
const [ series , setSeries ] = useState ( true ) ;
178
179
const [ action , setAction ] = useState ( false ) ;
179
180
181
+ const [ route , setRoute ] = useState ( null ) ;
182
+
180
183
useEffect ( ( ) => {
181
184
dispatch ( setCurrentTabInApp ( 'performance' ) ) ;
182
185
} , [ dispatch ] ) ;
@@ -188,7 +191,7 @@ const PerformanceVisx = (props: BarStackProps) => {
188
191
const actionsArr = [ ] ;
189
192
190
193
if ( seriesArr . length ) {
191
- for ( let i = 0 ; i < seriesArr . length ; i ++ ) {
194
+ for ( let i = 0 ; i < seriesArr . length ; i += 1 ) {
192
195
for ( const actionObj of seriesArr [ i ] . data . barStack ) {
193
196
if ( actionObj . name === action ) {
194
197
actionObj . seriesName = seriesArr [ i ] . name ;
@@ -227,9 +230,37 @@ const PerformanceVisx = (props: BarStackProps) => {
227
230
) ;
228
231
} ;
229
232
233
+ const allRoutes = [ ] ;
234
+ const filteredSnapshots = [ ] ;
235
+
236
+ for ( let i = 0 ; i < data . barStack . length ; i += 1 ) {
237
+ const url = new URL ( data . barStack [ i ] . route ) ;
238
+ if ( ! allRoutes . includes ( url . pathname ) ) {
239
+ allRoutes . push ( url . pathname ) ;
240
+ }
241
+ if ( route && route === url . pathname ) {
242
+ filteredSnapshots . push ( data . barStack [ i ] ) ;
243
+ }
244
+ }
245
+ if ( route ) {
246
+ data . barStack = filteredSnapshots ;
247
+ }
248
+
230
249
const renderBargraph = ( ) => {
231
250
if ( hierarchy ) {
232
- return < BarGraph data = { data } width = { width } height = { height } comparison = { allStorage ( ) } /> ;
251
+ return (
252
+ < div >
253
+ < BarGraph
254
+ data = { data }
255
+ width = { width }
256
+ height = { height }
257
+ comparison = { allStorage ( ) }
258
+ setRoute = { setRoute }
259
+ allRoutes = { allRoutes }
260
+ filteredSnapshots = { filteredSnapshots }
261
+ />
262
+ </ div >
263
+ ) ;
233
264
}
234
265
} ;
235
266
@@ -252,7 +283,6 @@ const PerformanceVisx = (props: BarStackProps) => {
252
283
< div className = "performance-nav-bar-container" >
253
284
< NavLink
254
285
className = "router-link-performance"
255
- // className="router-link"
256
286
activeClassName = "is-active"
257
287
exact
258
288
to = "/"
@@ -262,15 +292,13 @@ const PerformanceVisx = (props: BarStackProps) => {
262
292
< NavLink
263
293
className = "router-link-performance"
264
294
id = "router-link-performance-comparison"
265
- // className="router-link"
266
295
activeClassName = "is-active"
267
296
to = "/comparison"
268
297
>
269
298
Comparison View
270
299
</ NavLink >
271
300
< NavLink
272
301
className = "router-link-performance"
273
- // className="router-link"
274
302
activeClassName = "is-active"
275
303
to = "/componentdetails"
276
304
>
0 commit comments