@@ -66,23 +66,22 @@ const tooltipStyles = {
66
66
67
67
/* DATA HANDLING HELPER FUNCTIONS */
68
68
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
71
70
const traverse = ( snapshot , fetchData , data = { } ) => {
72
71
if ( ! snapshot . children [ 0 ] ) return ;
73
72
snapshot . children . forEach ( ( child , idx ) => {
74
73
const componentName = child . name + - [ idx + 1 ] ;
75
74
// Get component Type
76
- if ( fetchData === 'componentType ' ) {
75
+ if ( fetchData === 'getComponentType ' ) {
77
76
if ( child . state !== 'stateless' ) data [ componentName ] = 'STATEFUL' ;
78
77
else data [ componentName ] = child . state ;
79
78
}
80
79
// Get component Rendering Time
81
- else if ( fetchData === 'renderTime ' ) {
80
+ else if ( fetchData === 'getRenderTime ' ) {
82
81
const renderTime = Number ( Number . parseFloat ( child . componentData . actualDuration ) . toPrecision ( 5 ) ) ;
83
82
data [ componentName ] = renderTime ;
84
83
}
85
- else if ( fetchData === 'rtid ' ) {
84
+ else if ( fetchData === 'getRtid ' ) {
86
85
data [ componentName ] = child . rtid ;
87
86
}
88
87
traverse ( snapshot . children [ idx ] , fetchData , data ) ;
@@ -103,7 +102,7 @@ const getSnapshotIds = (obj, snapshotIds = []) => {
103
102
// Returns array of snapshot objs each with components and corresponding render times
104
103
const getPerfMetrics = ( snapshots , snapshotsIds ) :any [ ] => {
105
104
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 ] } ) ) ;
107
106
} , [ ] ) ;
108
107
} ;
109
108
@@ -123,12 +122,10 @@ const PerformanceVisx = (props: BarStackProps) => {
123
122
const { containerRef, TooltipInPortal } = useTooltipInPortal ( ) ;
124
123
125
124
// filter and structure incoming data for VISX
126
-
127
125
const data = getPerfMetrics ( snapshots , getSnapshotIds ( hierarchy ) ) ;
128
-
129
126
const keys = Object . keys ( data [ 0 ] ) . filter ( d => d !== 'snapshotId' ) ;
130
-
131
127
const allComponentStates = traverse ( snapshots [ 0 ] ) ;
128
+ const allComponentRtids = traverse ( snapshots [ - 1 ] , 'getRtids' ) ;
132
129
133
130
// create array of total render times for each snapshot
134
131
const totalRenderArr = data . reduce ( ( totalRender , curSnapshot ) => {
0 commit comments