module Sqreen::Backport::ClockGettime
Public Class Methods
supported?()
click to toggle source
# File lib/sqreen/backport/clock_gettime.rb, line 10 def supported? Process.respond_to?(:clock_gettime) end
Public Instance Methods
clock_gettime(clock_id, unit = :float_second)
click to toggle source
# File lib/sqreen/backport/clock_gettime.rb, line 50 def clock_gettime(clock_id, unit = :float_second) unless unit == :float_second raise "Process.clock_gettime: unsupported unit #{unit.inspect}" end t = Sqreen::Backport::ClockGettime::Timespec.new ret = Sqreen::Backport::ClockGettime::LibC.clock_gettime( clock_id, t.pointer, ) raise SystemCallError, "Errno #{FFI.errno}" if ret == -1 t[:tv_sec].to_f + t[:tv_nsec].to_f / 1_000_000_000 end