-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Stopwatch.GetTimestamp() doesn't take into account sleep time on Unix #77945
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @tommcdon Issue DetailsDescription
Discovered in PowerShell repo PowerShell/PowerShell#18469 Reproduction Steps
Expected behavior
Actual behavior
Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationRelated code runtime/src/native/libs/System.Native/pal_time.c Lines 84 to 97 in d320fd9
uses
|
We can use - #if HAVE_CLOCK_GETTIME_NSEC_NP
+ #if HAVE_CLOCK_GETTIME_NSEC_NP // macOS, FreeBSD
return clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
#else
struct timespec ts;
+ #ifdef CLOCK_BOOTTIME // Linux, Android
+ int result = clock_gettime(CLOCK_BOOTTIME, &ts);
+ #else // others
int result = clock_gettime(CLOCK_MONOTONIC, &ts);
+ #endif |
For MAC libuv/libuv#2891 |
Just to be clear, the current behavior which doesn't take into account suspended time doesn't match the |
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsDescription
Discovered in PowerShell repo PowerShell/PowerShell#18469 Reproduction Steps
Expected behavior
Actual behavior
Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationRelated code runtime/src/native/libs/System.Native/pal_time.c Lines 84 to 97 in d320fd9
|
This seems like shouldn't be a hard thing to fix and has seemingly looks to have a possible fix identified already above so I hope a PR with a fix will be raised soon |
Description
Stopwatch.GetTimestamp()
doesn't take into account suspend/sleep time on Unix but does on Windows.Discovered in PowerShell repo PowerShell/PowerShell#18469
Reproduction Steps
Stopwatch.GetTimestamp()
valueStopwatch.GetTimestamp()
valueExpected behavior
Stopwatch.GetTimestamp()
value takes into account the sleep time.Actual behavior
Stopwatch.GetTimestamp()
value doesn't take into account the sleep time on Unix.Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
Related code
runtime/src/native/libs/System.Native/pal_time.c
Lines 84 to 97 in d320fd9
uses- the bug seems to be right here. Should it beCLOCK_UPTIME_RAW
CLOCK_BOOTTIME
?The text was updated successfully, but these errors were encountered: