Sha256: cdfe215e045c3d5a81e6e04ba233abf25c02b50bd2798e680c98914bf0f4fdda

Contents?: true

Size: 642 Bytes

Versions: 3

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

module Rake
  module Funnel
    module Support
      module Timing
        class Statistics
          include Enumerable

          attr_reader :started_at

          def initialize
            @stats = []
            @started_at = Time.now
          end

          def each(&block)
            @stats.each(&block)
          end

          def benchmark(task)
            t0 = Time.now
            begin
              yield if block_given?
            ensure
              t1 = Time.now
              @stats << { task: task, time: t1 - t0 }
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake-funnel-0.24.0 lib/rake/funnel/support/timing/statistics.rb
rake-funnel-0.23.0 lib/rake/funnel/support/timing/statistics.rb
rake-funnel-0.22.3 lib/rake/funnel/support/timing/statistics.rb