Class: Rake::Funnel::Support::Timing::Statistics
- Inherits:
-
Object
- Object
- Rake::Funnel::Support::Timing::Statistics
- Includes:
- Enumerable
- Defined in:
- lib/rake/funnel/support/timing/statistics.rb
Instance Attribute Summary collapse
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
Instance Method Summary collapse
- #benchmark(task) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ Statistics
constructor
A new instance of Statistics.
Constructor Details
#initialize ⇒ Statistics
Returns a new instance of Statistics.
12 13 14 15 |
# File 'lib/rake/funnel/support/timing/statistics.rb', line 12 def initialize @stats = [] @started_at = Time.now end |
Instance Attribute Details
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
10 11 12 |
# File 'lib/rake/funnel/support/timing/statistics.rb', line 10 def started_at @started_at end |
Instance Method Details
#benchmark(task) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/rake/funnel/support/timing/statistics.rb', line 21 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
17 18 19 |
# File 'lib/rake/funnel/support/timing/statistics.rb', line 17 def each(&block) @stats.each(&block) end |