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



49
50
51
# File 'lib/ruby-metrics/time_units.rb', line 49

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

#scale_time_units(source, dest) ⇒ Object



53
54
55
# File 'lib/ruby-metrics/time_units.rb', line 53

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