123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::Benchmark

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: activesupport/lib/active_support/benchmark.rb

Class Method Summary

Class Method Details

.realtime(unit = :float_second, &block)

Benchmark realtime in the specified time unit. By default, the returned unit is in seconds.

ActiveSupport::Benchmark.realtime { sleep 0.1 }
# => 0.10007

ActiveSupport::Benchmark.realtime(:float_millisecond) { sleep 0.1 }
# => 100.07

unit can be any of the values accepted by Ruby’s Process.clock_gettime.

[ GitHub ]

  
# File 'activesupport/lib/active_support/benchmark.rb', line 15

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