-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add 20us tolerance to TestTotalProcessorTimeMacOs #116547
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
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process |
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.
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;
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) |
|
/ba-g System.Security.Cryptography.Tests DeadLetter'd |
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.