module ActiveSupport::Benchmark
def self.realtime(unit = :float_second, &block)
# => 100.07
ActiveSupport::Benchmark.realtime(:float_millisecond) { sleep 0.1 }
# => 0.10007
ActiveSupport::Benchmark.realtime { sleep 0.1 }
the returned unit is in seconds.
Benchmark realtime in the specified time unit. By default,
:nodoc:
def self.realtime(unit = :float_second, &block) time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC, unit) yield Process.clock_gettime(Process::CLOCK_MONOTONIC, unit) - time_start end