module Sqreen has_mono_time = begin Process.clock_gettime Process::CLOCK_MONOTONIC true rescue StandardError false end @has_thread_cpu_time = begin Process.clock_gettime Process::CLOCK_THREAD_CPUTIME_ID true rescue StandardError false end class << self def thread_cpu_time? @has_thread_cpu_time end end if has_mono_time def self.time Process.clock_gettime Process::CLOCK_MONOTONIC end else def self.time Time.now.to_f end end if @has_thread_cpu_time def self.thread_cpu_time Process.clock_gettime Process::CLOCK_THREAD_CPUTIME_ID end else def self.thread_cpu_time 0 end end end