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
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_at ⇒ Object (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 |