Sha256: 763c5b421be00853842589843eaf70382b55693024734cda9c96d43859150ef1
Contents?: true
Size: 751 Bytes
Versions: 3
Compression:
Stored size: 751 Bytes
Contents
require 'ur' unless Object.const_defined?(:Ur) class Ur class Processing include SubUr def began_at began_at_s ? Time.parse(began_at_s) : nil end def began_at=(time) self.began_at_s = time ? time.utc.iso8601(6) : nil end attr_accessor :began_at_ns def begin! self.began_at ||= Time.now self.began_at_ns ||= Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond) end def finish! return if duration if began_at_ns now_ns = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond) self.duration = (now_ns - began_at_ns) * 1e-9 elsif began_at now = Time.now self.duration = (now.to_f - began_at.to_f) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ur-0.0.4 | lib/ur/processing.rb |
ur-0.0.3 | lib/ur/processing.rb |
ur-0.0.2 | lib/ur/processing.rb |