-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Brian Vaughn
authored
Jan 28, 2022
1 parent
2ed58eb
commit fa816be
Showing
49 changed files
with
10,716 additions
and
4,497 deletions.
There are no files selected for viewing
3,193 changes: 2,243 additions & 950 deletions
3,193
packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js
Large diffs are not rendered by default.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
packages/react-devtools-shared/src/__tests__/__serializers__/profilingSerializer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/react-devtools-shared/src/__tests__/__serializers__/timelineDataSerializer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
}); | ||
} |
Oops, something went wrong.