Sha256: 2aaf9a353d2dfa72451d1c6471584bf8e5cf5e488de232729fff54fa00d47af5

Contents?: true

Size: 619 Bytes

Versions: 2

Compression:

Stored size: 619 Bytes

Contents

module Staccato
  # Timing Hit type field definitions
  # @author Tony Pitale
  class Timing
    # Timing field definitions
    FIELDS = {
      category: 'utc',
      variable: 'utv',
      label: 'utl',
      time: 'utt'
    }

    include Hit

    # timing hit type
    def type
      :timing
    end

    # tracks the timing hit type
    # @param block [#call] block is executed and time recorded
    def track!(&block)
      if block_given?
        start_at = Time.now
        block.call
        end_at = Time.now

        self.options.time = (end_at - start_at).to_i*1000
      end

      super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
staccato-0.0.4 lib/staccato/timing.rb
staccato-0.0.3 lib/staccato/timing.rb