@samitouri / QOS-React-2 / commits / d42f86bb50

Updated Profiling chart tests to cover components with duration=0

Brian Vaughn committed May 8, 2019 at 14:35 UTC d42f86bb50e5b49edf05e8e51f043f6b7c3d46f8
2 files changed +104 -43
src/__tests__/__snapshots__/profilingCharts-test.js.snap
+89 -31
@@ -11,18 +11,19 @@ Object {
11 "id": 1,
12 "key": null,
13 "parentID": 0,
14 - "treeBaseDuration": 14,
14 + "treeBaseDuration": 15,
15 },
16 2 => Object {
17 "children": Array [
18 3,
19 4,
20 + 5,
21 ],
22 "displayName": "Parent",
23 "id": 2,
24 "key": null,
25 "parentID": 1,
25 - "treeBaseDuration": 14,
26 + "treeBaseDuration": 15,
27 },
28 3 => Object {
29 "children": Array [],
@@ -30,7 +31,7 @@ Object {
31 "id": 3,
32 "key": "first",
33 "parentID": 2,
33 - "treeBaseDuration": 2,
34 + "treeBaseDuration": 3,
35 },
36 4 => Object {
37 "children": Array [],
@@ -40,6 +41,14 @@ Object {
41 "parentID": 2,
42 "treeBaseDuration": 2,
43 },
44 + 5 => Object {
45 + "children": Array [],
46 + "displayName": "Memo(Child)",
47 + "id": 5,
48 + "key": "third",
49 + "parentID": 2,
50 + "treeBaseDuration": 0,
51 + },
52 },
53 "rootID": 1,
54 }
@@ -47,10 +56,11 @@ Object {
56
57 exports[`profiling charts flamegraph chart should contain valid data: 0: FlamegraphChartData 1`] = `
58 Object {
50 - "baseDuration": 14,
59 + "baseDuration": 15,
60 "depth": 2,
61 "idToDepthMap": Map {
62 2 => 1,
63 + 5 => 2,
64 4 => 2,
65 3 => 2,
66 },
@@ -58,36 +68,46 @@ Object {
68 "rows": Array [
69 Array [
70 Object {
61 - "actualDuration": 14,
71 + "actualDuration": 15,
72 "didRender": true,
73 "id": 2,
64 - "label": "Parent (10ms of 14ms)",
74 + "label": "Parent (10ms of 15ms)",
75 "name": "Parent",
76 "offset": 0,
77 "selfDuration": 10,
68 - "treeBaseDuration": 14,
78 + "treeBaseDuration": 15,
79 },
80 ],
81 Array [
82 + Object {
83 + "actualDuration": 0,
84 + "didRender": false,
85 + "id": 5,
86 + "label": "Memo(Child) key=\\"third\\"",
87 + "name": "Memo(Child)",
88 + "offset": 15,
89 + "selfDuration": 0,
90 + "treeBaseDuration": 0,
91 + },
92 Object {
93 "actualDuration": 2,
94 "didRender": true,
95 "id": 4,
96 "label": "Memo(Child) key=\\"second\\" (2ms of 2ms)",
97 "name": "Memo(Child)",
78 - "offset": 12,
98 + "offset": 13,
99 "selfDuration": 2,
100 "treeBaseDuration": 2,
101 },
102 Object {
83 - "actualDuration": 2,
103 + "actualDuration": 3,
104 "didRender": true,
105 "id": 3,
86 - "label": "Memo(Child) key=\\"first\\" (2ms of 2ms)",
106 + "label": "Memo(Child) key=\\"first\\" (3ms of 3ms)",
107 "name": "Memo(Child)",
108 "offset": 10,
89 - "selfDuration": 2,
90 - "treeBaseDuration": 2,
109 + "selfDuration": 3,
110 + "treeBaseDuration": 3,
111 },
112 ],
113 ],
@@ -105,18 +125,19 @@ Object {
125 "id": 1,
126 "key": null,
127 "parentID": 0,
108 - "treeBaseDuration": 14,
128 + "treeBaseDuration": 15,
129 },
130 2 => Object {
131 "children": Array [
132 3,
133 4,
134 + 5,
135 ],
136 "displayName": "Parent",
137 "id": 2,
138 "key": null,
139 "parentID": 1,
119 - "treeBaseDuration": 14,
140 + "treeBaseDuration": 15,
141 },
142 3 => Object {
143 "children": Array [],
@@ -124,7 +145,7 @@ Object {
145 "id": 3,
146 "key": "first",
147 "parentID": 2,
127 - "treeBaseDuration": 2,
148 + "treeBaseDuration": 3,
149 },
150 4 => Object {
151 "children": Array [],
@@ -134,6 +155,14 @@ Object {
155 "parentID": 2,
156 "treeBaseDuration": 2,
157 },
158 + 5 => Object {
159 + "children": Array [],
160 + "displayName": "Memo(Child)",
161 + "id": 5,
162 + "key": "third",
163 + "parentID": 2,
164 + "treeBaseDuration": 0,
165 + },
166 },
167 "rootID": 1,
168 }
@@ -141,10 +170,11 @@ Object {
170
171 exports[`profiling charts flamegraph chart should contain valid data: 1: FlamegraphChartData 1`] = `
172 Object {
144 - "baseDuration": 14,
173 + "baseDuration": 15,
174 "depth": 2,
175 "idToDepthMap": Map {
176 2 => 1,
177 + 5 => 2,
178 4 => 2,
179 3 => 2,
180 },
@@ -159,17 +189,27 @@ Object {
189 "name": "Parent",
190 "offset": 0,
191 "selfDuration": 10,
162 - "treeBaseDuration": 14,
192 + "treeBaseDuration": 15,
193 },
194 ],
195 Array [
196 + Object {
197 + "actualDuration": 0,
198 + "didRender": false,
199 + "id": 5,
200 + "label": "Memo(Child) key=\\"third\\"",
201 + "name": "Memo(Child)",
202 + "offset": 15,
203 + "selfDuration": 0,
204 + "treeBaseDuration": 0,
205 + },
206 Object {
207 "actualDuration": 0,
208 "didRender": false,
209 "id": 4,
210 "label": "Memo(Child) key=\\"second\\"",
211 "name": "Memo(Child)",
172 - "offset": 12,
212 + "offset": 13,
213 "selfDuration": 0,
214 "treeBaseDuration": 2,
215 },
@@ -181,7 +221,7 @@ Object {
221 "name": "Memo(Child)",
222 "offset": 10,
223 "selfDuration": 0,
184 - "treeBaseDuration": 2,
224 + "treeBaseDuration": 3,
225 },
226 ],
227 ],
@@ -190,15 +230,15 @@ Object {
230
231 exports[`profiling charts interactions should contain valid data: Interactions 1`] = `
232 Object {
193 - "lastInteractionTime": 24,
194 - "maxCommitDuration": 14,
233 + "lastInteractionTime": 25,
234 + "maxCommitDuration": 15,
235 }
236 `;
237
238 exports[`profiling charts interactions should contain valid data: Interactions 2`] = `
239 Object {
200 - "lastInteractionTime": 24,
201 - "maxCommitDuration": 14,
240 + "lastInteractionTime": 25,
241 + "maxCommitDuration": 15,
242 }
243 `;
244
@@ -213,18 +253,19 @@ Object {
253 "id": 1,
254 "key": null,
255 "parentID": 0,
216 - "treeBaseDuration": 14,
256 + "treeBaseDuration": 15,
257 },
258 2 => Object {
259 "children": Array [
260 3,
261 4,
262 + 5,
263 ],
264 "displayName": "Parent",
265 "id": 2,
266 "key": null,
267 "parentID": 1,
227 - "treeBaseDuration": 14,
268 + "treeBaseDuration": 15,
269 },
270 3 => Object {
271 "children": Array [],
@@ -232,7 +273,7 @@ Object {
273 "id": 3,
274 "key": "first",
275 "parentID": 2,
235 - "treeBaseDuration": 2,
276 + "treeBaseDuration": 3,
277 },
278 4 => Object {
279 "children": Array [],
@@ -242,6 +283,14 @@ Object {
283 "parentID": 2,
284 "treeBaseDuration": 2,
285 },
286 + 5 => Object {
287 + "children": Array [],
288 + "displayName": "Memo(Child)",
289 + "id": 5,
290 + "key": "third",
291 + "parentID": 2,
292 + "treeBaseDuration": 0,
293 + },
294 },
295 "rootID": 1,
296 }
@@ -259,9 +308,9 @@ Object {
308 },
309 Object {
310 "id": 3,
262 - "label": "Memo(Child) key=\\"first\\" (2ms)",
311 + "label": "Memo(Child) key=\\"first\\" (3ms)",
312 "name": "Memo(Child)",
264 - "value": 2,
313 + "value": 3,
314 },
315 Object {
316 "id": 4,
@@ -284,18 +333,19 @@ Object {
333 "id": 1,
334 "key": null,
335 "parentID": 0,
287 - "treeBaseDuration": 14,
336 + "treeBaseDuration": 15,
337 },
338 2 => Object {
339 "children": Array [
340 3,
341 4,
342 + 5,
343 ],
344 "displayName": "Parent",
345 "id": 2,
346 "key": null,
347 "parentID": 1,
298 - "treeBaseDuration": 14,
348 + "treeBaseDuration": 15,
349 },
350 3 => Object {
351 "children": Array [],
@@ -303,7 +353,7 @@ Object {
353 "id": 3,
354 "key": "first",
355 "parentID": 2,
306 - "treeBaseDuration": 2,
356 + "treeBaseDuration": 3,
357 },
358 4 => Object {
359 "children": Array [],
@@ -313,6 +363,14 @@ Object {
363 "parentID": 2,
364 "treeBaseDuration": 2,
365 },
366 + 5 => Object {
367 + "children": Array [],
368 + "displayName": "Memo(Child)",
369 + "id": 5,
370 + "key": "third",
371 + "parentID": 2,
372 + "treeBaseDuration": 0,
373 + },
374 },
375 "rootID": 1,
376 }
src/__tests__/profilingCharts-test.js
+15 -12
@@ -32,15 +32,16 @@ describe('profiling charts', () => {
32 Scheduler.advanceTime(10);
33 return (
34 <React.Fragment>
35 - <Child key="first" />
36 - <Child key="second" />
35 + <Child key="first" duration={3} />
36 + <Child key="second" duration={2} />
37 + <Child key="third" duration={0} />
38 </React.Fragment>
39 );
40 };
41
42 // Memoize children to verify that chart doesn't include in the update.
42 - const Child = React.memo(function Child() {
43 - Scheduler.advanceTime(2);
43 + const Child = React.memo(function Child({ duration }) {
44 + Scheduler.advanceTime(duration);
45 return null;
46 });
47
@@ -125,15 +126,16 @@ describe('profiling charts', () => {
126 Scheduler.advanceTime(10);
127 return (
128 <React.Fragment>
128 - <Child key="first" />
129 - <Child key="second" />
129 + <Child key="first" duration={3} />
130 + <Child key="second" duration={2} />
131 + <Child key="third" duration={0} />
132 </React.Fragment>
133 );
134 };
135
136 // Memoize children to verify that chart doesn't include in the update.
135 - const Child = React.memo(function Child() {
136 - Scheduler.advanceTime(2);
137 + const Child = React.memo(function Child({ duration }) {
138 + Scheduler.advanceTime(duration);
139 return null;
140 });
141
@@ -214,15 +216,16 @@ describe('profiling charts', () => {
216 Scheduler.advanceTime(10);
217 return (
218 <React.Fragment>
217 - <Child key="first" />
218 - <Child key="second" />
219 + <Child key="first" duration={3} />
220 + <Child key="second" duration={2} />
221 + <Child key="third" duration={0} />
222 </React.Fragment>
223 );
224 };
225
226 // Memoize children to verify that chart doesn't include in the update.
224 - const Child = React.memo(function Child() {
225 - Scheduler.advanceTime(2);
227 + const Child = React.memo(function Child({ duration }) {
228 + Scheduler.advanceTime(duration);
229 return null;
230 });
231