5

Refactor `Process.clock_gettime` uses by casperisfine · Pull Request #43502 · ra...

 3 years ago
source link: https://github.com/rails/rails/pull/43502
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

casperisfine commented on Oct 21

edited

Ref: ruby-concurrency/concurrent-ruby#915

Two things here

Concurrent.monotonic_time

This was useful a long time ago (pre Ruby 2.3), but now all the supported rubies have Process.clock_gettime(Process::CLOCK_MONOTONIC), so we might as well save a method call, especially in these tight loops.

unit argument.

Rather than applying * 1000 to get milliseconds, you can directly ask for milliseconds with Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond).

Opening a PR simply to make sure I didn't break CI.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK