Module: Timber::Timer

Defined in:
lib/timber/timer.rb

Overview

This is an ultra-simple abstraction for timing code. This provides a little more control around how Timber automatically processes “timers”.

Examples:

timer = Timber::Timer.start
# ... code to time
logger.info("My log message", my_event: {time_ms: timer})

Class Method Summary collapse

Class Method Details

.duration_ms(timer) ⇒ Object

Get the duration in milliseconds from the object returned in #start



16
17
18
19
# File 'lib/timber/timer.rb', line 16

def self.duration_ms(timer)
  now = Time.now
  (now - timer) * 1000.0
end

.startObject

Abstract for starting a timber. Currently this is simply calling ‘Time.now`.



11
12
13
# File 'lib/timber/timer.rb', line 11

def self.start
  Time.now
end