Class: Kuroko2::MemoryConsumptionLog::Interval
- Inherits:
-
Object
- Object
- Kuroko2::MemoryConsumptionLog::Interval
- Defined in:
- app/models/kuroko2/memory_consumption_log.rb
Overview
As count becames greater, the interval period will be longer. First interval will be 1 second and next interval will be 1 second too, then next interval will be 4 seconds then next interval will be 9 seconds. Finally, maximum of interval will be 30 minutes.
Constant Summary collapse
- INITIAL_INTERVAL_PERIOD =
1.second.to_i
- MAX_INTERVAL_PERIOD =
30.minutes.to_i
- INCREMENT =
2
Instance Attribute Summary collapse
-
#base_time ⇒ Object
readonly
Returns the value of attribute base_time.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
-
#initialize(base_time, count = 0) ⇒ Interval
constructor
A new instance of Interval.
- #next ⇒ MemoryConsumptionLog::Interval
- #reached?(now) ⇒ Boolean
Constructor Details
#initialize(base_time, count = 0) ⇒ Interval
Returns a new instance of Interval.
21 22 23 24 |
# File 'app/models/kuroko2/memory_consumption_log.rb', line 21 def initialize(base_time, count = 0) @base_time = base_time @count = [count, 50].min end |
Instance Attribute Details
#base_time ⇒ Object (readonly)
Returns the value of attribute base_time.
17 18 19 |
# File 'app/models/kuroko2/memory_consumption_log.rb', line 17 def base_time @base_time end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
17 18 19 |
# File 'app/models/kuroko2/memory_consumption_log.rb', line 17 def count @count end |
Instance Method Details
#next ⇒ MemoryConsumptionLog::Interval
33 34 35 |
# File 'app/models/kuroko2/memory_consumption_log.rb', line 33 def next self.class.new(Time.at(@base_time.to_i + current_length), @count.succ) end |
#reached?(now) ⇒ Boolean
28 29 30 |
# File 'app/models/kuroko2/memory_consumption_log.rb', line 28 def reached?(now) (now - @base_time) > current_length end |