Sha256: 76ede78de245cb3d1661028c0cdd0c59dd814a3e7f191631d38a8ea4cbe62e28

Contents?: true

Size: 619 Bytes

Versions: 36

Compression:

Stored size: 619 Bytes

Contents

module Timber
  # This is an ultra-simple abstraction for timing code. This provides a little
  # more control around how Timber automatically processes "timers".
  #
  # @example
  #   timer = Timber::Timer.start
  #   # ... code to time
  #   logger.info("My log message", my_event: {time_ms: timer})
  module Timer
    # Abstract for starting a timber. Currently this is simply calling `Time.now`.
    def self.start
      Time.now
    end

    # Get the duration in milliseconds from the object returned in {#start}
    def self.duration_ms(timer)
      now = Time.now
      (now - timer) * 1000.0
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
timber-2.1.9 lib/timber/timer.rb
timber-2.1.8 lib/timber/timer.rb
timber-2.1.7 lib/timber/timer.rb
timber-2.1.6 lib/timber/timer.rb
timber-2.1.5 lib/timber/timer.rb
timber-2.1.4 lib/timber/timer.rb
timber-2.1.3 lib/timber/timer.rb
timber-2.1.2 lib/timber/timer.rb
timber-2.1.1 lib/timber/timer.rb
timber-2.1.0 lib/timber/timer.rb
timber-2.1.0.rc6 lib/timber/timer.rb
timber-2.1.0.rc5 lib/timber/timer.rb
timber-2.1.0.rc4 lib/timber/timer.rb
timber-2.1.0.rc3 lib/timber/timer.rb
timber-2.1.0.rc2 lib/timber/timer.rb
timber-2.1.0.rc1 lib/timber/timer.rb