-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor[react-devtools/fiber/renderer]: optimize durations resolution #31118
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -331,3 +331,12 @@ export function parseSourceFromComponentStack( | |
|
||
return parseSourceFromFirefoxStack(componentStack); | ||
} | ||
|
||
// 0.123456789 => 0.123 | ||
// Expects high-resolution timestamp in milliseconds, like from performance.now() | ||
// Mainly used for optimizing the size of serialized profiling payload | ||
export function formatDurationToMicrosecondsGranularity( | ||
duration: number, | ||
): number { | ||
return Math.round(duration * 1000) / 1000; | ||
} | ||
Comment on lines
+334
to
+342
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would there be a risk of the frontend precision being out of sync with this here? I'd imagine an all-in solution involving the frontend declaring a precision somehow. (not saying we need it in this PR tho) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, yes, if we decide to start showing durations with increased granularity. This is not the case for browser extension, though, because backend and frontend are shipped in a single version lockstep. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be cleaner to have
formatDurationToMicrosecondsGranularity
take null? (I don't have a preference)