Skip to content

Commit fa816be

Browse files
author
Brian Vaughn
authored
DevTools: Timeline profiler refactor
Refactor DevTools to record Timeline data (in memory) while profiling. Updated the Profiler UI to import/export Timeline data along with legacy profiler data. Relates to issue #22529
1 parent 2ed58eb commit fa816be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+10716
-4497
lines changed

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

+2,243-950
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import hasOwnProperty from 'shared/hasOwnProperty';
2+
3+
const FILTERED_VERSION_STRING = '<filtered-version>';
4+
5+
// test() is part of Jest's serializer API
6+
export function test(maybeProfile) {
7+
if (
8+
maybeProfile != null &&
9+
typeof maybeProfile === 'object' &&
10+
hasOwnProperty.call(maybeProfile, 'reactVersion') &&
11+
maybeProfile.reactVersion !== FILTERED_VERSION_STRING
12+
) {
13+
return true;
14+
}
15+
16+
return false;
17+
}
18+
19+
// print() is part of Jest's serializer API
20+
export function print(profile, serialize, indent) {
21+
return serialize({
22+
...profile,
23+
reactVersion: FILTERED_VERSION_STRING,
24+
});
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import hasOwnProperty from 'shared/hasOwnProperty';
2+
import isArray from 'shared/isArray';
3+
4+
function formatLanes(laneArray) {
5+
const lanes = laneArray.reduce((current, reduced) => current + reduced, 0);
6+
return '0b' + lanes.toString(2).padStart(31, '0');
7+
}
8+
9+
// test() is part of Jest's serializer API
10+
export function test(maybeTimelineData) {
11+
if (
12+
maybeTimelineData != null &&
13+
typeof maybeTimelineData === 'object' &&
14+
hasOwnProperty.call(maybeTimelineData, 'lanes') &&
15+
isArray(maybeTimelineData.lanes)
16+
) {
17+
return true;
18+
}
19+
20+
return false;
21+
}
22+
23+
// print() is part of Jest's serializer API
24+
export function print(timelineData, serialize, indent) {
25+
return serialize({
26+
...timelineData,
27+
lanes: formatLanes(timelineData.lanes),
28+
});
29+
}

0 commit comments

Comments
 (0)