Add 20us tolerance to TestTotalProcessorTimeMacOs#116547
Merged
jozkee merged 2 commits intodotnet:mainfrom Oct 21, 2025
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process |
Contributor
There was a problem hiding this comment.
Pull Request Overview
The PR adds a microsecond-level tolerance to the macOS processor time test to account for small discrepancies between the managed and native APIs.
- Introduces a
ToleranceInMicrosecondsconstant and computes the time difference in microseconds - Updates the assertion to allow a ±20 μs deviation
- Adjusts the error message to mention the tolerance
Comments suppressed due to low confidence (1)
src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs:882
- TimeSpan does not have a
TotalMicrosecondsproperty. Consider computing microseconds via(managed - native).Ticks / 10or(managed - native).TotalMilliseconds * 1000.
double differenceUs = (managed - native).TotalMicroseconds;
3 tasks
jeffhandley
reviewed
Oct 20, 2025
tarekgh
reviewed
Oct 20, 2025
Member
Just to tell, we have Environment.CpuUsage too. just FYI if you want to double check against it too. not required though. Refers to: src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs:857 in 171b2cd. [](commit_id = 171b2cd, deletion_comment = False) |
tarekgh
approved these changes
Oct 20, 2025
Member
Author
|
/ba-g System.Security.Cryptography.Tests DeadLetter'd |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found on a release/9.0 build https://dev.azure.com/dnceng-public/public/_build/results?buildId=1064508
there was a 4 microsecond difference between the time calculated using macOS'
proc_pid_rusageandmach_timebase_infoandProcess.UserProcessorTime.I want to believe this was caused by rounding and/or precision differences between the macOS specific methods the test uses vs getrusage, used by the product.
Running the test locally on M1, I see the difference in the assertion is 655us.