I learned about Process::CLOCK_MONOTONIC. It should be used instead of system time updates when measuring elapsed time because it ensures that the measurement is accurate and not affected by system time updates.

started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
do_something(args)
ended_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)