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-3.0.1 lib/timber/timer.rb
timber-3.0.0 lib/timber/timer.rb
timber-2.6.2 lib/timber/timer.rb
timber-2.6.1 lib/timber/timer.rb
timber-2.6.0 lib/timber/timer.rb
timber-2.6.0.pre.beta2 lib/timber/timer.rb
timber-2.6.0.pre.beta1 lib/timber/timer.rb
timber-2.5.1 lib/timber/timer.rb
timber-2.5.0 lib/timber/timer.rb
timber-2.4.0 lib/timber/timer.rb
timber-2.3.4 lib/timber/timer.rb
timber-2.3.3 lib/timber/timer.rb
timber-2.3.2 lib/timber/timer.rb
timber-2.3.1 lib/timber/timer.rb
timber-2.3.0 lib/timber/timer.rb
timber-2.2.3 lib/timber/timer.rb
timber-2.2.2 lib/timber/timer.rb
timber-2.2.1 lib/timber/timer.rb
timber-2.2.0 lib/timber/timer.rb
timber-2.1.10 lib/timber/timer.rb