Skip to content

Commit

Permalink
Squashed PRs 23137, 23141, 23157
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Jan 21, 2022
1 parent 13036bf commit eaff284
Show file tree
Hide file tree
Showing 20 changed files with 830 additions and 697 deletions.
886 changes: 398 additions & 488 deletions packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ Object {
1,
11,
0,
1,
3,
1,
1,
4,
Expand Down Expand Up @@ -1186,7 +1186,7 @@ Object {
1,
11,
0,
1,
3,
1,
1,
4,
Expand Down Expand Up @@ -1663,7 +1663,7 @@ Object {
13,
11,
0,
1,
3,
1,
1,
4,
Expand Down Expand Up @@ -2209,7 +2209,7 @@ Object {
13,
11,
0,
1,
3,
1,
1,
4,
Expand Down Expand Up @@ -2304,7 +2304,7 @@ Object {
1,
11,
0,
1,
3,
1,
1,
1,
Expand Down Expand Up @@ -2954,7 +2954,7 @@ Object {
1,
11,
0,
1,
3,
1,
1,
1,
Expand Down Expand Up @@ -4227,7 +4227,7 @@ Object {
1,
11,
0,
1,
3,
1,
1,
1,
Expand Down
79 changes: 41 additions & 38 deletions packages/react-devtools-shared/src/__tests__/preprocessData-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ describe('Timeline profiler', () => {
.setPerformanceMock_ONLY_FOR_TESTING;
setPerformanceMock(createUserTimingPolyfill());

const store = global.store;

// Start profiling so that data will actually be recorded.
utils.act(() => store.profilerStore.startProfiling());

global.IS_REACT_ACT_ENVIRONMENT = true;
});

Expand Down Expand Up @@ -392,7 +397,7 @@ describe('Timeline profiler', () => {
"suspenseEvents": Array [],
"thrownErrors": Array [],
}
`);
`);
});

it('should process legacy data format (before lane labels were added)', async () => {
Expand Down Expand Up @@ -609,7 +614,7 @@ describe('Timeline profiler', () => {
"suspenseEvents": Array [],
"thrownErrors": Array [],
}
`);
`);
});

it('should process a sample legacy render sequence', async () => {
Expand All @@ -626,11 +631,11 @@ describe('Timeline profiler', () => {
Object {
"batchUID": 0,
"depth": 0,
"duration": 0.01,
"duration": 0.005,
"lanes": Array [
0,
],
"timestamp": 0.004,
"timestamp": 0.009,
"type": "render-idle",
},
Object {
Expand All @@ -640,17 +645,17 @@ describe('Timeline profiler', () => {
"lanes": Array [
0,
],
"timestamp": 0.004,
"timestamp": 0.009,
"type": "render",
},
Object {
"batchUID": 0,
"depth": 0,
"duration": 0.008,
"duration": 0.003,
"lanes": Array [
0,
],
"timestamp": 0.006,
"timestamp": 0.011,
"type": "commit",
},
Object {
Expand Down Expand Up @@ -718,11 +723,11 @@ describe('Timeline profiler', () => {
Object {
"batchUID": 0,
"depth": 0,
"duration": 0.01,
"duration": 0.005,
"lanes": Array [
0,
],
"timestamp": 0.004,
"timestamp": 0.009,
"type": "render-idle",
},
Object {
Expand All @@ -732,17 +737,17 @@ describe('Timeline profiler', () => {
"lanes": Array [
0,
],
"timestamp": 0.004,
"timestamp": 0.009,
"type": "render",
},
Object {
"batchUID": 0,
"depth": 0,
"duration": 0.008,
"duration": 0.003,
"lanes": Array [
0,
],
"timestamp": 0.006,
"timestamp": 0.011,
"type": "commit",
},
Object {
Expand Down Expand Up @@ -796,7 +801,7 @@ describe('Timeline profiler', () => {
"lanes": Array [
0,
],
"timestamp": 0.003,
"timestamp": 0.008,
"type": "schedule-render",
"warning": null,
},
Expand Down Expand Up @@ -835,11 +840,11 @@ describe('Timeline profiler', () => {
Object {
"batchUID": 0,
"depth": 0,
"duration": 0.012,
"duration": 0.007,
"lanes": Array [
4,
],
"timestamp": 0.004,
"timestamp": 0.009,
"type": "render-idle",
},
Object {
Expand All @@ -849,17 +854,17 @@ describe('Timeline profiler', () => {
"lanes": Array [
4,
],
"timestamp": 0.004,
"timestamp": 0.009,
"type": "render",
},
Object {
"batchUID": 0,
"depth": 0,
"duration": 0.008,
"duration": 0.003,
"lanes": Array [
4,
],
"timestamp": 0.008,
"timestamp": 0.013,
"type": "commit",
},
Object {
Expand Down Expand Up @@ -887,7 +892,7 @@ describe('Timeline profiler', () => {
Object {
"batchUID": 1,
"depth": 0,
"duration": 0.012,
"duration": 0.007,
"lanes": Array [
4,
],
Expand All @@ -907,7 +912,7 @@ describe('Timeline profiler', () => {
Object {
"batchUID": 1,
"depth": 0,
"duration": 0.008,
"duration": 0.003,
"lanes": Array [
4,
],
Expand All @@ -921,7 +926,7 @@ describe('Timeline profiler', () => {
"lanes": Array [
4,
],
"timestamp": 0.032,
"timestamp": 0.027,
"type": "layout-effects",
},
Object {
Expand All @@ -931,7 +936,7 @@ describe('Timeline profiler', () => {
"lanes": Array [
4,
],
"timestamp": 0.035,
"timestamp": 0.03,
"type": "passive-effects",
},
],
Expand All @@ -940,7 +945,7 @@ describe('Timeline profiler', () => {
Object {
"componentName": "App",
"duration": 0.001,
"timestamp": 0.005,
"timestamp": 0.01,
"type": "render",
"warning": null,
},
Expand All @@ -961,12 +966,12 @@ describe('Timeline profiler', () => {
Object {
"componentName": "App",
"duration": 0.001,
"timestamp": 0.036,
"timestamp": 0.031,
"type": "passive-effect-mount",
"warning": null,
},
],
"duration": 0.038,
"duration": 0.033,
"flamechart": Array [],
"internalModuleSourceToRanges": Map {
undefined => Array [
Expand Down Expand Up @@ -1022,11 +1027,11 @@ describe('Timeline profiler', () => {
Object {
"batchUID": 0,
"depth": 0,
"duration": 0.012,
"duration": 0.007,
"lanes": Array [
4,
],
"timestamp": 0.004,
"timestamp": 0.009,
"type": "render-idle",
},
Object {
Expand All @@ -1036,17 +1041,17 @@ describe('Timeline profiler', () => {
"lanes": Array [
4,
],
"timestamp": 0.004,
"timestamp": 0.009,
"type": "render",
},
Object {
"batchUID": 0,
"depth": 0,
"duration": 0.008,
"duration": 0.003,
"lanes": Array [
4,
],
"timestamp": 0.008,
"timestamp": 0.013,
"type": "commit",
},
Object {
Expand All @@ -1072,7 +1077,7 @@ describe('Timeline profiler', () => {
Object {
"batchUID": 1,
"depth": 0,
"duration": 0.012,
"duration": 0.007,
"lanes": Array [
4,
],
Expand All @@ -1092,7 +1097,7 @@ describe('Timeline profiler', () => {
Object {
"batchUID": 1,
"depth": 0,
"duration": 0.008,
"duration": 0.003,
"lanes": Array [
4,
],
Expand All @@ -1106,7 +1111,7 @@ describe('Timeline profiler', () => {
"lanes": Array [
4,
],
"timestamp": 0.032,
"timestamp": 0.027,
"type": "layout-effects",
},
Object {
Expand All @@ -1116,7 +1121,7 @@ describe('Timeline profiler', () => {
"lanes": Array [
4,
],
"timestamp": 0.035,
"timestamp": 0.03,
"type": "passive-effects",
},
],
Expand Down Expand Up @@ -1156,7 +1161,7 @@ describe('Timeline profiler', () => {
"lanes": Array [
4,
],
"timestamp": 0.003,
"timestamp": 0.008,
"type": "schedule-render",
"warning": null,
},
Expand Down Expand Up @@ -1253,7 +1258,7 @@ describe('Timeline profiler', () => {
"timestamp": 0.005,
},
]
`);
`);
});

it('should include a suspended resource "displayName" if one is set', async () => {
Expand Down Expand Up @@ -1840,8 +1845,6 @@ describe('Timeline profiler', () => {
),
);

clearPendingMarks();

const testMarks = [creactCpuProfilerSample()];

// Start profiling and suspend during a render.
Expand Down
8 changes: 4 additions & 4 deletions packages/react-devtools-shared/src/__tests__/store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,17 +915,17 @@ describe('Store', () => {
const containerA = document.createElement('div');
const containerB = document.createElement('div');

expect(store.supportsProfiling).toBe(false);
expect(store.rootSupportsBasicProfiling).toBe(false);

act(() => legacyRender(<Component />, containerA));
expect(store.supportsProfiling).toBe(true);
expect(store.rootSupportsBasicProfiling).toBe(true);

act(() => legacyRender(<Component />, containerB));
act(() => ReactDOM.unmountComponentAtNode(containerA));
expect(store.supportsProfiling).toBe(true);
expect(store.rootSupportsBasicProfiling).toBe(true);

act(() => ReactDOM.unmountComponentAtNode(containerB));
expect(store.supportsProfiling).toBe(false);
expect(store.rootSupportsBasicProfiling).toBe(false);
});

it('should properly serialize non-string key values', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export function attach(
pushOperation(id);
pushOperation(ElementTypeRoot);
pushOperation(0); // StrictMode compliant?
pushOperation(0); // Profiling supported?
pushOperation(0); // Profiling flag
pushOperation(0); // StrictMode supported?
pushOperation(hasOwnerMetadata ? 1 : 0);
} else {
Expand Down
Loading

0 comments on commit eaff284

Please sign in to comment.