class Airbrake::Benchmark
Benchmark
benchmarks Ruby code.
@since v4.2.4 @api public
Attributes
duration[R]
@return [Float]
Public Class Methods
measure() { || ... }
click to toggle source
Measures monotonic time for the given operation.
@yieldreturn [void]
# File lib/airbrake-ruby/benchmark.rb, line 10 def self.measure benchmark = new yield benchmark.stop benchmark.duration end
new()
click to toggle source
@since v4.3.0
# File lib/airbrake-ruby/benchmark.rb, line 23 def initialize @start = MonotonicTime.time_in_ms @duration = 0.0 end
Public Instance Methods
stop()
click to toggle source
Stops the benchmark and stores `duration`.
@since v4.3.0 @return [Boolean] true for the first invocation, false in all other cases
# File lib/airbrake-ruby/benchmark.rb, line 32 def stop return false if @duration > 0.0 @duration = MonotonicTime.time_in_ms - @start true end