diff options
author | Niklas Hambüchen <mail@nh2.me> | 2017-09-19 15:09:29 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-09-19 15:58:45 -0400 |
commit | 28a115e5e2c3c19b860545f1fcde4317bac3ee2a (patch) | |
tree | 35b97efde537ab5d79bb9abe4cf71c7a9c2d8961 /includes/rts | |
parent | 7c7914d02a7ff189aba2f4feca31366fb4ab2664 (diff) | |
download | haskell-28a115e5e2c3c19b860545f1fcde4317bac3ee2a.tar.gz |
base: fdReady(): Improve accuracy and simplify code.
This is done by reusing the existing cross-platform
`getProcessElapsedTime()` function, which already provides nanosecond
monotonic clocks, and fallback for platforms that don't have those.
To do this, `getProcessElapsedTime()` had to be moved from a private RTS
symbol into the public interface.
Accuracy is improved in 2 ways:
* Use of the monotonic clock where available
* Measuring the total time spent waiting instead of a sum
of intervals (between which there are small gaps)
Reviewers: bgamari, austin, hvr, erikd, simonmar
Reviewed By: bgamari
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3953
Diffstat (limited to 'includes/rts')
-rw-r--r-- | includes/rts/Time.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/includes/rts/Time.h b/includes/rts/Time.h index 5fa166e125..12c6d2767d 100644 --- a/includes/rts/Time.h +++ b/includes/rts/Time.h @@ -21,8 +21,10 @@ typedef int64_t Time; #if TIME_RESOLUTION == 1000000000 // I'm being lazy, but it's awkward to define fully general versions of these +#define TimeToMS(t) ((t) / 1000000) #define TimeToUS(t) ((t) / 1000) #define TimeToNS(t) (t) +#define MSToTime(t) ((Time)(t) * 1000000) #define USToTime(t) ((Time)(t) * 1000) #define NSToTime(t) ((Time)(t)) #else @@ -38,3 +40,5 @@ INLINE_HEADER Time fsecondsToTime (double t) { return (Time)(t * TIME_RESOLUTION); } + +Time getProcessElapsedTime (void); |