Class: Airbrake::Benchmark
- Inherits:
-
Object
- Object
- Airbrake::Benchmark
- Defined in:
- lib/airbrake-ruby/benchmark.rb
Overview
Benchmark benchmarks Ruby code.
Instance Attribute Summary collapse
- #duration ⇒ Float readonly
Class Method Summary collapse
-
.measure ⇒ Object
Measures monotonic time for the given operation.
Instance Method Summary collapse
-
#initialize ⇒ Benchmark
constructor
A new instance of Benchmark.
-
#stop ⇒ Boolean
Stops the benchmark and stores ‘duration`.
Constructor Details
#initialize ⇒ Benchmark
Returns a new instance of Benchmark.
23 24 25 26 |
# File 'lib/airbrake-ruby/benchmark.rb', line 23 def initialize @start = MonotonicTime.time_in_ms @duration = 0.0 end |
Instance Attribute Details
#duration ⇒ Float (readonly)
20 21 22 |
# File 'lib/airbrake-ruby/benchmark.rb', line 20 def duration @duration end |
Class Method Details
.measure ⇒ Object
Measures monotonic time for the given operation.
10 11 12 13 14 15 16 17 |
# File 'lib/airbrake-ruby/benchmark.rb', line 10 def self.measure benchmark = new yield benchmark.stop benchmark.duration end |
Instance Method Details
#stop ⇒ Boolean
Stops the benchmark and stores ‘duration`.
32 33 34 35 36 37 |
# File 'lib/airbrake-ruby/benchmark.rb', line 32 def stop return false if @duration > 0.0 @duration = MonotonicTime.time_in_ms - @start true end |