-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Only measure "base" times within ProfileMode #12821
Conversation
34ac646
to
25c1d6a
Compare
25c1d6a
to
27706f7
Compare
@@ -396,7 +396,9 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>( | |||
nextChildren = null; | |||
|
|||
if (enableProfilerTimer) { | |||
stopBaseRenderTimerIfRunning(); | |||
if (workInProgress.mode & ProfileMode) { |
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.
Why do you need to conditionally stop it? Stopping something already stopped is as cheap as checking the flag, probably cheaper, right?
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.
Totally. This is why I had the question in the PR description:
Should I remove the conditionals around stopBaseRenderTimerIfRunning? (Is it worth having them?)
I was on the fence.
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.
I'll just back out 27706f7 😄
…also" This reverts commit 27706f7.
Follow up for this comment on PR #12745. Previously I was tracking base time for all fibers, regardless of whether they were inside of a
Profiler
, because the place where I started the timer didn't yet know if it was in aProfileMode
.I could move where I start/stop the timer somewhere else- where it would know- but this approach seemed simpler. It has a small potential downside of not measuring "base" time for the
Profiler
component itself- but I think this is okay because (1) that time should be minimal and (2) it isn't really actionable for a developer.Questions
Should I remove the conditionals aroundstopBaseRenderTimerIfRunning
? (Is it worth having them?)Caveats
ProfileMode
tree. This only updates a single numeric value though; it doesn't modify any attributes on a fiber.