Class: Rack::Stats::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/stats/timer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



13
14
15
# File 'lib/rack/stats/timer.rb', line 13

def duration
  @duration
end

Instance Method Details

#time(&blk) ⇒ Object



15
16
17
18
19
20
# File 'lib/rack/stats/timer.rb', line 15

def time(&blk)
  t0 = Time.now.nsec
  r = blk.call
  @duration = Duration.new(Time.now.nsec - t0)
  r
end