Class: Funk::Instruments::Timings

Inherits:
Object
  • Object
show all
Defined in:
lib/funk/instruments/timings.rb

Instance Method Summary collapse

Constructor Details

#initializeTimings

Returns a new instance of Timings.



4
5
6
# File 'lib/funk/instruments/timings.rb', line 4

def initialize()
  @timings = {}
end

Instance Method Details

#after_call(fn, input, value) ⇒ Object



12
13
14
# File 'lib/funk/instruments/timings.rb', line 12

def after_call(fn, input, value)
  @timings[fn.name][:end] = Time.now
end

#before_call(fn, input) ⇒ Object



8
9
10
# File 'lib/funk/instruments/timings.rb', line 8

def before_call(fn, input)
  @timings[fn.name] = {:start => Time.now}
end

#eachObject



16
17
18
19
20
21
22
# File 'lib/funk/instruments/timings.rb', line 16

def each
  @timings.sort {|a,b|
    a[1][:start] <=> b[1][:start]
  }.each do |t|
    yield t[0], t[1]
  end
end