Class: Gruf::Interceptors::Timer
- Inherits:
-
Object
- Object
- Gruf::Interceptors::Timer
- Defined in:
- lib/gruf/interceptors/timer.rb
Overview
Utility class that can be used by interceptors to time requests
Defined Under Namespace
Classes: Result
Class Method Summary collapse
-
.time ⇒ Gruf::Interceptors::Timer::Result
Time a given code block and return a Timer::Result object.
Class Method Details
.time ⇒ Gruf::Interceptors::Timer::Result
Time a given code block and return a Timer::Result object
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/gruf/interceptors/timer.rb', line 70 def self.time start_time = Time.now = yield end_time = Time.now elapsed = (end_time - start_time) * 1000.0 Result.new(, elapsed, true) rescue GRPC::BadStatus => e end_time = Time.now elapsed = (end_time - start_time) * 1000.0 Result.new(e, elapsed, false) end |