Class: Rake::Funnel::Support::Timing::Statistics

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rake/funnel/support/timing/statistics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatistics



10
11
12
13
# File 'lib/rake/funnel/support/timing/statistics.rb', line 10

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

Instance Attribute Details

#started_atObject (readonly)

Returns the value of attribute started_at.



8
9
10
# File 'lib/rake/funnel/support/timing/statistics.rb', line 8

def started_at
  @started_at
end

Instance Method Details

#benchmark(task) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/rake/funnel/support/timing/statistics.rb', line 19

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

#each(&block) ⇒ Object



15
16
17
# File 'lib/rake/funnel/support/timing/statistics.rb', line 15

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