Class: Contrast::Utils::Timer
Overview
Timer is class that can track state about when an event starts and how long it takes Also containes utility methods to get time values in milliseconds
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#start_ms ⇒ Object
readonly
Returns the value of attribute start_ms.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(time = Time.now) ⇒ Timer
constructor
A new instance of Timer.
Constructor Details
#initialize(time = Time.now) ⇒ Timer
Returns a new instance of Timer.
11 12 13 14 15 |
# File 'lib/contrast/utils/timer.rb', line 11 def initialize time = Time.now @start_at = time @start_ms = (@start_at.to_f * 1000).to_i @events = {} end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
9 10 11 |
# File 'lib/contrast/utils/timer.rb', line 9 def events @events end |
#start_ms ⇒ Object (readonly)
Returns the value of attribute start_ms.
9 10 11 |
# File 'lib/contrast/utils/timer.rb', line 9 def start_ms @start_ms end |
Class Method Details
.now_ms ⇒ Object
17 18 19 |
# File 'lib/contrast/utils/timer.rb', line 17 def self.now_ms (Time.now.to_f * 1000).to_i end |