Class: OpenWFE::Timer
- Inherits:
-
Object
- Object
- OpenWFE::Timer
- Defined in:
- lib/openwfe/utils.rb
Overview
A small Timer class for debug purposes.
t = Time.new
# ... do something
puts "that something took #{t.duration} ms"
Instance Attribute Summary collapse
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
-
#duration ⇒ Object
Returns the number of milliseconds since this Timer was instantiated.
-
#initialize ⇒ Timer
constructor
A new instance of Timer.
Constructor Details
#initialize ⇒ Timer
Returns a new instance of Timer.
334 335 336 |
# File 'lib/openwfe/utils.rb', line 334 def initialize @start = Time.now.to_f end |
Instance Attribute Details
#start ⇒ Object (readonly)
Returns the value of attribute start.
332 333 334 |
# File 'lib/openwfe/utils.rb', line 332 def start @start end |
Instance Method Details
#duration ⇒ Object
Returns the number of milliseconds since this Timer was instantiated.
342 343 344 |
# File 'lib/openwfe/utils.rb', line 342 def duration (Time.now.to_f - @start) * 1000 end |