class Gruf::Timer
Times a given block and returns the result and the elapsed time as a Float
result = Timer.time { do_my_thing }
Public Class Methods
time() { || ... }
click to toggle source
Times a given block by recording start and end times
result = Timer.time { do_my_thing }
@return [Timer::Result] Returns the timed result of the block
# File lib/gruf/timer.rb, line 67 def self.time start_time = Time.now begin result = yield rescue GRPC::BadStatus, StandardError, GRPC::Core::CallError => e result = e end end_time = Time.now elapsed = (end_time - start_time) * 1000.0 Result.new(result, elapsed) end