This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Fix System.Diagnostics.Process.[x]ProcessorTime on macOS#37637
Merged
danmoseley merged 8 commits intodotnet:masterfrom May 15, 2019
Merged
Fix System.Diagnostics.Process.[x]ProcessorTime on macOS#37637danmoseley merged 8 commits intodotnet:masterfrom
danmoseley merged 8 commits intodotnet:masterfrom
Conversation
The ri_user_time unit is nanoseconds, but the TimeSpan .ctor expects values with a 100-nanosecond unit.
Contributor
Author
Looks very similar to #31908 - cc @ViktorHofer. Added |
stephentoub
reviewed
May 14, 2019
stephentoub
reviewed
May 14, 2019
stephentoub
reviewed
May 14, 2019
danmoseley
reviewed
May 15, 2019
danmoseley
approved these changes
May 15, 2019
danmoseley
reviewed
May 15, 2019
Member
|
I'll merge since you can fix in that other PR. |
Member
|
Thanks @gregkalapos ! After fixing the typo, we would welcome other contributions. Any interest? |
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
…fx#37637) * Fix System.Diagnostics.Process xProcessorTime props and add test The ri_user_time unit is nanoseconds, but the TimeSpan .ctor expects values with a 100-nanosecond unit. * Update src/System.Diagnostics.Process/tests/ProcessTests.cs * Update src/System.Diagnostics.Process/tests/ProcessTests.cs * Update src/System.Diagnostics.Process/tests/ProcessTests.cs * Update src/System.Diagnostics.Process/tests/ProcessTests.cs * Add ActiveIssue to TotalProcessorTime_PerformLoop_TotalProcessorTimeValid * Address PR feedback * Fix typo - NanoSeconds -> Nanoseconds Commit migrated from dotnet/corefx@a28176b
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.
Fixes #37614
Affects on macOS:
Process.UserProcessorTimeProcess.PrivilegedProcessorTimeProcess.TotalProcessorTimeDiscussed with @stephentoub in #37614, this PR implements the proposed fix.
Short summary (more in #37614):
The
rusage_info_v3mac API uses nanoseconds unit, which was passed without any conversion toTimeSpan’s Int64-based constructor, which expects a value with a 100-nanosecond unit. Therfore values reported on macOS were 100x of the correct value.Fix: we simply convert the
rusage_info_v3nanosec values to 100-nanosec unit.Also added a test, which fails with the original code on my machine and passes with the code in this PR. Since the
TestProcessorTimetest is disabled for UWP (https://github.com/dotnet/corefx/issues/31908) I suspect we will have similar problems with the new test. Let's see...