Class: GroongaQueryLog::Command::Analyzer::WorkerStatistic
- Inherits:
-
Object
- Object
- GroongaQueryLog::Command::Analyzer::WorkerStatistic
- Defined in:
- lib/groonga-query-log/command/analyzer/worker-statistic.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#idle_time_max ⇒ Object
readonly
Returns the value of attribute idle_time_max.
-
#idle_time_mean ⇒ Object
readonly
Returns the value of attribute idle_time_mean.
-
#idle_time_min ⇒ Object
readonly
Returns the value of attribute idle_time_min.
-
#idle_time_total ⇒ Object
readonly
Returns the value of attribute idle_time_total.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#n_statistics ⇒ Object
readonly
Returns the value of attribute n_statistics.
Instance Method Summary collapse
- #<<(statistic) ⇒ Object
-
#initialize(id) ⇒ WorkerStatistic
constructor
A new instance of WorkerStatistic.
Constructor Details
#initialize(id) ⇒ WorkerStatistic
Returns a new instance of WorkerStatistic.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/groonga-query-log/command/analyzer/worker-statistic.rb', line 28 def initialize(id) @id = id @idle_time_total = 0.0 @idle_time_mean = 0.0 @idle_time_min = 0.0 @idle_time_max = 0.0 @n_statistics = 0 @metrics = { timestamp: [], idle_time: [], elapsed: [], } @previous_statistic = nil end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/groonga-query-log/command/analyzer/worker-statistic.rb', line 21 def id @id end |
#idle_time_max ⇒ Object (readonly)
Returns the value of attribute idle_time_max.
25 26 27 |
# File 'lib/groonga-query-log/command/analyzer/worker-statistic.rb', line 25 def idle_time_max @idle_time_max end |
#idle_time_mean ⇒ Object (readonly)
Returns the value of attribute idle_time_mean.
23 24 25 |
# File 'lib/groonga-query-log/command/analyzer/worker-statistic.rb', line 23 def idle_time_mean @idle_time_mean end |
#idle_time_min ⇒ Object (readonly)
Returns the value of attribute idle_time_min.
24 25 26 |
# File 'lib/groonga-query-log/command/analyzer/worker-statistic.rb', line 24 def idle_time_min @idle_time_min end |
#idle_time_total ⇒ Object (readonly)
Returns the value of attribute idle_time_total.
22 23 24 |
# File 'lib/groonga-query-log/command/analyzer/worker-statistic.rb', line 22 def idle_time_total @idle_time_total end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
27 28 29 |
# File 'lib/groonga-query-log/command/analyzer/worker-statistic.rb', line 27 def metrics @metrics end |
#n_statistics ⇒ Object (readonly)
Returns the value of attribute n_statistics.
26 27 28 |
# File 'lib/groonga-query-log/command/analyzer/worker-statistic.rb', line 26 def n_statistics @n_statistics end |
Instance Method Details
#<<(statistic) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/groonga-query-log/command/analyzer/worker-statistic.rb', line 43 def <<(statistic) @n_statistics += 1 if @previous_statistic idle_time = statistic.start_time - @previous_statistic.end_time @idle_time_total += idle_time @idle_time_mean += ((idle_time - @idle_time_mean) / @n_statistics) if @idle_time_min.zero? @idle_time_min = idle_time else @idle_time_min = [@idle_time_min, idle_time].min end @idle_time_max = [@idle_time_max, idle_time].max @metrics[:timestamp] << statistic.start_time @metrics[:idle_time] << idle_time @metrics[:elapsed] << statistic.elapsed_in_seconds end @previous_statistic = statistic end |