Skip to content

Commit eaff284

Browse files
author
Brian Vaughn
committed
Squashed PRs 23137, 23141, 23157
1 parent 13036bf commit eaff284

20 files changed

+830
-697
lines changed

packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js

Lines changed: 398 additions & 488 deletions
Large diffs are not rendered by default.

packages/react-devtools-shared/src/__tests__/__snapshots__/profilingCache-test.js.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ Object {
720720
1,
721721
11,
722722
0,
723-
1,
723+
3,
724724
1,
725725
1,
726726
4,
@@ -1186,7 +1186,7 @@ Object {
11861186
1,
11871187
11,
11881188
0,
1189-
1,
1189+
3,
11901190
1,
11911191
1,
11921192
4,
@@ -1663,7 +1663,7 @@ Object {
16631663
13,
16641664
11,
16651665
0,
1666-
1,
1666+
3,
16671667
1,
16681668
1,
16691669
4,
@@ -2209,7 +2209,7 @@ Object {
22092209
13,
22102210
11,
22112211
0,
2212-
1,
2212+
3,
22132213
1,
22142214
1,
22152215
4,
@@ -2304,7 +2304,7 @@ Object {
23042304
1,
23052305
11,
23062306
0,
2307-
1,
2307+
3,
23082308
1,
23092309
1,
23102310
1,
@@ -2954,7 +2954,7 @@ Object {
29542954
1,
29552955
11,
29562956
0,
2957-
1,
2957+
3,
29582958
1,
29592959
1,
29602960
1,
@@ -4227,7 +4227,7 @@ Object {
42274227
1,
42284228
11,
42294229
0,
4230-
1,
4230+
3,
42314231
1,
42324232
1,
42334233
1,

packages/react-devtools-shared/src/__tests__/preprocessData-test.js

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ describe('Timeline profiler', () => {
8181
.setPerformanceMock_ONLY_FOR_TESTING;
8282
setPerformanceMock(createUserTimingPolyfill());
8383

84+
const store = global.store;
85+
86+
// Start profiling so that data will actually be recorded.
87+
utils.act(() => store.profilerStore.startProfiling());
88+
8489
global.IS_REACT_ACT_ENVIRONMENT = true;
8590
});
8691

@@ -392,7 +397,7 @@ describe('Timeline profiler', () => {
392397
"suspenseEvents": Array [],
393398
"thrownErrors": Array [],
394399
}
395-
`);
400+
`);
396401
});
397402

398403
it('should process legacy data format (before lane labels were added)', async () => {
@@ -609,7 +614,7 @@ describe('Timeline profiler', () => {
609614
"suspenseEvents": Array [],
610615
"thrownErrors": Array [],
611616
}
612-
`);
617+
`);
613618
});
614619

615620
it('should process a sample legacy render sequence', async () => {
@@ -626,11 +631,11 @@ describe('Timeline profiler', () => {
626631
Object {
627632
"batchUID": 0,
628633
"depth": 0,
629-
"duration": 0.01,
634+
"duration": 0.005,
630635
"lanes": Array [
631636
0,
632637
],
633-
"timestamp": 0.004,
638+
"timestamp": 0.009,
634639
"type": "render-idle",
635640
},
636641
Object {
@@ -640,17 +645,17 @@ describe('Timeline profiler', () => {
640645
"lanes": Array [
641646
0,
642647
],
643-
"timestamp": 0.004,
648+
"timestamp": 0.009,
644649
"type": "render",
645650
},
646651
Object {
647652
"batchUID": 0,
648653
"depth": 0,
649-
"duration": 0.008,
654+
"duration": 0.003,
650655
"lanes": Array [
651656
0,
652657
],
653-
"timestamp": 0.006,
658+
"timestamp": 0.011,
654659
"type": "commit",
655660
},
656661
Object {
@@ -718,11 +723,11 @@ describe('Timeline profiler', () => {
718723
Object {
719724
"batchUID": 0,
720725
"depth": 0,
721-
"duration": 0.01,
726+
"duration": 0.005,
722727
"lanes": Array [
723728
0,
724729
],
725-
"timestamp": 0.004,
730+
"timestamp": 0.009,
726731
"type": "render-idle",
727732
},
728733
Object {
@@ -732,17 +737,17 @@ describe('Timeline profiler', () => {
732737
"lanes": Array [
733738
0,
734739
],
735-
"timestamp": 0.004,
740+
"timestamp": 0.009,
736741
"type": "render",
737742
},
738743
Object {
739744
"batchUID": 0,
740745
"depth": 0,
741-
"duration": 0.008,
746+
"duration": 0.003,
742747
"lanes": Array [
743748
0,
744749
],
745-
"timestamp": 0.006,
750+
"timestamp": 0.011,
746751
"type": "commit",
747752
},
748753
Object {
@@ -796,7 +801,7 @@ describe('Timeline profiler', () => {
796801
"lanes": Array [
797802
0,
798803
],
799-
"timestamp": 0.003,
804+
"timestamp": 0.008,
800805
"type": "schedule-render",
801806
"warning": null,
802807
},
@@ -835,11 +840,11 @@ describe('Timeline profiler', () => {
835840
Object {
836841
"batchUID": 0,
837842
"depth": 0,
838-
"duration": 0.012,
843+
"duration": 0.007,
839844
"lanes": Array [
840845
4,
841846
],
842-
"timestamp": 0.004,
847+
"timestamp": 0.009,
843848
"type": "render-idle",
844849
},
845850
Object {
@@ -849,17 +854,17 @@ describe('Timeline profiler', () => {
849854
"lanes": Array [
850855
4,
851856
],
852-
"timestamp": 0.004,
857+
"timestamp": 0.009,
853858
"type": "render",
854859
},
855860
Object {
856861
"batchUID": 0,
857862
"depth": 0,
858-
"duration": 0.008,
863+
"duration": 0.003,
859864
"lanes": Array [
860865
4,
861866
],
862-
"timestamp": 0.008,
867+
"timestamp": 0.013,
863868
"type": "commit",
864869
},
865870
Object {
@@ -887,7 +892,7 @@ describe('Timeline profiler', () => {
887892
Object {
888893
"batchUID": 1,
889894
"depth": 0,
890-
"duration": 0.012,
895+
"duration": 0.007,
891896
"lanes": Array [
892897
4,
893898
],
@@ -907,7 +912,7 @@ describe('Timeline profiler', () => {
907912
Object {
908913
"batchUID": 1,
909914
"depth": 0,
910-
"duration": 0.008,
915+
"duration": 0.003,
911916
"lanes": Array [
912917
4,
913918
],
@@ -921,7 +926,7 @@ describe('Timeline profiler', () => {
921926
"lanes": Array [
922927
4,
923928
],
924-
"timestamp": 0.032,
929+
"timestamp": 0.027,
925930
"type": "layout-effects",
926931
},
927932
Object {
@@ -931,7 +936,7 @@ describe('Timeline profiler', () => {
931936
"lanes": Array [
932937
4,
933938
],
934-
"timestamp": 0.035,
939+
"timestamp": 0.03,
935940
"type": "passive-effects",
936941
},
937942
],
@@ -940,7 +945,7 @@ describe('Timeline profiler', () => {
940945
Object {
941946
"componentName": "App",
942947
"duration": 0.001,
943-
"timestamp": 0.005,
948+
"timestamp": 0.01,
944949
"type": "render",
945950
"warning": null,
946951
},
@@ -961,12 +966,12 @@ describe('Timeline profiler', () => {
961966
Object {
962967
"componentName": "App",
963968
"duration": 0.001,
964-
"timestamp": 0.036,
969+
"timestamp": 0.031,
965970
"type": "passive-effect-mount",
966971
"warning": null,
967972
},
968973
],
969-
"duration": 0.038,
974+
"duration": 0.033,
970975
"flamechart": Array [],
971976
"internalModuleSourceToRanges": Map {
972977
undefined => Array [
@@ -1022,11 +1027,11 @@ describe('Timeline profiler', () => {
10221027
Object {
10231028
"batchUID": 0,
10241029
"depth": 0,
1025-
"duration": 0.012,
1030+
"duration": 0.007,
10261031
"lanes": Array [
10271032
4,
10281033
],
1029-
"timestamp": 0.004,
1034+
"timestamp": 0.009,
10301035
"type": "render-idle",
10311036
},
10321037
Object {
@@ -1036,17 +1041,17 @@ describe('Timeline profiler', () => {
10361041
"lanes": Array [
10371042
4,
10381043
],
1039-
"timestamp": 0.004,
1044+
"timestamp": 0.009,
10401045
"type": "render",
10411046
},
10421047
Object {
10431048
"batchUID": 0,
10441049
"depth": 0,
1045-
"duration": 0.008,
1050+
"duration": 0.003,
10461051
"lanes": Array [
10471052
4,
10481053
],
1049-
"timestamp": 0.008,
1054+
"timestamp": 0.013,
10501055
"type": "commit",
10511056
},
10521057
Object {
@@ -1072,7 +1077,7 @@ describe('Timeline profiler', () => {
10721077
Object {
10731078
"batchUID": 1,
10741079
"depth": 0,
1075-
"duration": 0.012,
1080+
"duration": 0.007,
10761081
"lanes": Array [
10771082
4,
10781083
],
@@ -1092,7 +1097,7 @@ describe('Timeline profiler', () => {
10921097
Object {
10931098
"batchUID": 1,
10941099
"depth": 0,
1095-
"duration": 0.008,
1100+
"duration": 0.003,
10961101
"lanes": Array [
10971102
4,
10981103
],
@@ -1106,7 +1111,7 @@ describe('Timeline profiler', () => {
11061111
"lanes": Array [
11071112
4,
11081113
],
1109-
"timestamp": 0.032,
1114+
"timestamp": 0.027,
11101115
"type": "layout-effects",
11111116
},
11121117
Object {
@@ -1116,7 +1121,7 @@ describe('Timeline profiler', () => {
11161121
"lanes": Array [
11171122
4,
11181123
],
1119-
"timestamp": 0.035,
1124+
"timestamp": 0.03,
11201125
"type": "passive-effects",
11211126
},
11221127
],
@@ -1156,7 +1161,7 @@ describe('Timeline profiler', () => {
11561161
"lanes": Array [
11571162
4,
11581163
],
1159-
"timestamp": 0.003,
1164+
"timestamp": 0.008,
11601165
"type": "schedule-render",
11611166
"warning": null,
11621167
},
@@ -1253,7 +1258,7 @@ describe('Timeline profiler', () => {
12531258
"timestamp": 0.005,
12541259
},
12551260
]
1256-
`);
1261+
`);
12571262
});
12581263

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

1843-
clearPendingMarks();
1844-
18451848
const testMarks = [creactCpuProfilerSample()];
18461849

18471850
// Start profiling and suspend during a render.

packages/react-devtools-shared/src/__tests__/store-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,17 +915,17 @@ describe('Store', () => {
915915
const containerA = document.createElement('div');
916916
const containerB = document.createElement('div');
917917

918-
expect(store.supportsProfiling).toBe(false);
918+
expect(store.rootSupportsBasicProfiling).toBe(false);
919919

920920
act(() => legacyRender(<Component />, containerA));
921-
expect(store.supportsProfiling).toBe(true);
921+
expect(store.rootSupportsBasicProfiling).toBe(true);
922922

923923
act(() => legacyRender(<Component />, containerB));
924924
act(() => ReactDOM.unmountComponentAtNode(containerA));
925-
expect(store.supportsProfiling).toBe(true);
925+
expect(store.rootSupportsBasicProfiling).toBe(true);
926926

927927
act(() => ReactDOM.unmountComponentAtNode(containerB));
928-
expect(store.supportsProfiling).toBe(false);
928+
expect(store.rootSupportsBasicProfiling).toBe(false);
929929
});
930930

931931
it('should properly serialize non-string key values', () => {

packages/react-devtools-shared/src/backend/legacy/renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export function attach(
387387
pushOperation(id);
388388
pushOperation(ElementTypeRoot);
389389
pushOperation(0); // StrictMode compliant?
390-
pushOperation(0); // Profiling supported?
390+
pushOperation(0); // Profiling flag
391391
pushOperation(0); // StrictMode supported?
392392
pushOperation(hasOwnerMetadata ? 1 : 0);
393393
} else {

0 commit comments

Comments
 (0)