Class: MicroBench::Benchmark
- Inherits:
-
Object
- Object
- MicroBench::Benchmark
- Defined in:
- lib/micro_bench/benchmark.rb
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize ⇒ Benchmark
constructor
A new instance of Benchmark.
- #running? ⇒ Boolean
- #stop ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Benchmark
Returns a new instance of Benchmark.
4 5 6 |
# File 'lib/micro_bench/benchmark.rb', line 4 def initialize @start_time = monotonic_clock_time end |
Instance Method Details
#duration ⇒ Object
16 17 18 |
# File 'lib/micro_bench/benchmark.rb', line 16 def duration @duration || (monotonic_clock_time - @start_time) end |
#running? ⇒ Boolean
20 21 22 |
# File 'lib/micro_bench/benchmark.rb', line 20 def running? @duration.nil? end |
#stop ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/micro_bench/benchmark.rb', line 8 def stop return false unless running? @duration = monotonic_clock_time - @start_time return true end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/micro_bench/benchmark.rb', line 24 def to_s duration.to_s end |