Module: Metrics::TimeConversion

Included in:
Instruments::Meter, Instruments::Timer
Defined in:
lib/ruby-metrics/time_units.rb

Constant Summary collapse

UNITS =
{
    :nanoseconds            => Nanoseconds,
    :microseconds           => Microseconds,
    :milliseconds           => Milliseconds,
    :seconds                => Seconds,
    :minutes                => Minutes,
    :hours                  => Hours
}

Instance Method Summary collapse

Instance Method Details

#convert_to_ns(value, unit) ⇒ Object



55
56
57
# File 'lib/ruby-metrics/time_units.rb', line 55

def convert_to_ns(value, unit)
  (UNITS[unit].to_nsec.to_f * value.to_f)
end

#scale_time_units(source, dest) ⇒ Object



59
60
61
# File 'lib/ruby-metrics/time_units.rb', line 59

def scale_time_units(source, dest)
  (UNITS[source].to_nsec.to_f) / (UNITS[dest].to_nsec.to_f)
end