Class: OpenWFE::Timer

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeTimer

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

#startObject (readonly)

Returns the value of attribute start.



332
333
334
# File 'lib/openwfe/utils.rb', line 332

def start
  @start
end

Instance Method Details

#durationObject

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