Method: Gruf::Timer.time
- Defined in:
- lib/gruf/timer.rb
.time ⇒ Timer::Result
Times a given block by recording start and end times
result = Timer.time { do_my_thing }
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/gruf/timer.rb', line 66 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 |