Closed casperisfine closed 3 years ago
When is defined?(Process::CLOCK_MONOTONIC)
false?
It's not false on JRuby 9.2.17.0 for example. Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
works fine on JRuby, TruffleRuby, and I'm guessing not even Rubinius but it's hard to build these days.
@headius do you know if this is some kind of ancient fallback?
Older MRI I think. Process.clock_gettime
was added in 2.3 if my memory serves me right.
Oh right didn't realise it was so recent. I will check against older versions and build up a matrix of what is supported where.
Seems good to merge when CI passes on older Rubies.
I'll look at the TruffleRuby failure that's unrelated.
@chrisseaton I believe I fixed the CI (well it has various failures but unrelated to the current PR).
I also think the implementation is now simpler, as for the simple case of Process.clock_getime
being present we save one method call.
I'm sorry that CI is in such a mess. We really need to get a grip of it.
This is a direct transposition of MRI's
clock_gettime
unit option.Tis is a parameter I use quite a lot when writing MRI specific code, but that I miss when using
Concurrent.monotonic_time
for portability.More often than not, when you reach for monotonic time, you want to minimize the overhead, so it's appreciable to be able to avoid a
/ 1_000
when you want milliseconds in the first place.NB: I'm not too sure how a good way to test the scale of the return value would be.