Skip to content

Commit

Permalink
DevTools: Timeline profiler refactor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Brian Vaughn authored Jan 28, 2022
1 parent 2ed58eb commit fa816be
Show file tree
Hide file tree
Showing 49 changed files with 10,716 additions and 4,497 deletions.
3,193 changes: 2,243 additions & 950 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
@@ -0,0 +1,25 @@
import hasOwnProperty from 'shared/hasOwnProperty';

const FILTERED_VERSION_STRING = '<filtered-version>';

// test() is part of Jest's serializer API
export function test(maybeProfile) {
if (
maybeProfile != null &&
typeof maybeProfile === 'object' &&
hasOwnProperty.call(maybeProfile, 'reactVersion') &&
maybeProfile.reactVersion !== FILTERED_VERSION_STRING
) {
return true;
}

return false;
}

// print() is part of Jest's serializer API
export function print(profile, serialize, indent) {
return serialize({
...profile,
reactVersion: FILTERED_VERSION_STRING,
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import hasOwnProperty from 'shared/hasOwnProperty';
import isArray from 'shared/isArray';

function formatLanes(laneArray) {
const lanes = laneArray.reduce((current, reduced) => current + reduced, 0);
return '0b' + lanes.toString(2).padStart(31, '0');
}

// test() is part of Jest's serializer API
export function test(maybeTimelineData) {
if (
maybeTimelineData != null &&
typeof maybeTimelineData === 'object' &&
hasOwnProperty.call(maybeTimelineData, 'lanes') &&
isArray(maybeTimelineData.lanes)
) {
return true;
}

return false;
}

// print() is part of Jest's serializer API
export function print(timelineData, serialize, indent) {
return serialize({
...timelineData,
lanes: formatLanes(timelineData.lanes),
});
}
Loading

0 comments on commit fa816be

Please sign in to comment.