-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
System.Diagnostics.Stopwatch When measuring small time periods #90788
Comments
Tagging subscribers to this area: @tommcdon Issue DetailsDescriptionThe GetRawElapsedTicks() method dose not handle possebility of negative values.
Simple fix:
I would like to suggest a little restructuring of the StopMethod on the System.Diagnostics.Stopwatch. The current implementation allows negativ values in elapsedThisPeriod to be added to _elapsed and resets _elapsed if the total is a negativ value.
Would it not make more sens to skip adding negativ values to _elapsed?
Or is the rationell due to some performance consideration in regards to the if-statement?
|
Does this actually happen, I thought the underlying timestamp sources was monotonically increasing. See here
and also won't roll over during a reasonable lifetime
|
Closing as a dupe of #66734. As described in similar issues/related PRs:
|
Description
The GetRawElapsedTicks() method dose not handle possebility of negative values.
Simple fix:
I would like to suggest a little restructuring of the StopMethod on the System.Diagnostics.Stopwatch.
The current implementation allows negativ values in elapsedThisPeriod to be added to _elapsed and resets _elapsed if the total is a negativ value.
Would it not make more sens to skip adding negativ values to _elapsed?
Or is the rationell due to some performance consideration in regards to the if-statement?
The text was updated successfully, but these errors were encountered: