Class: Roby::EventLogging::IOEventLogger::TimepointGroupStats
- Defined in:
- lib/roby/event_logging/io_event_logger.rb
Instance Attribute Summary collapse
-
#fifo ⇒ Object
Returns the value of attribute fifo.
-
#last_duration ⇒ Object
Returns the value of attribute last_duration.
-
#max_duration ⇒ Object
Returns the value of attribute max_duration.
-
#mean ⇒ Object
Returns the value of attribute mean.
-
#min_duration ⇒ Object
Returns the value of attribute min_duration.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#sample_count ⇒ Object
Returns the value of attribute sample_count.
-
#sum_squares ⇒ Object
Returns the value of attribute sum_squares.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
- #mean_delta(old_mean, duration, new_count) ⇒ Object
- #sum_squares_delta(duration, old_mean, new_mean) ⇒ Object
- #to_s ⇒ Object
- #update(duration) ⇒ Object
- #update_min_max(duration) ⇒ Object
- #update_statistics(duration, new_count) ⇒ Object
- #variance ⇒ Object
Instance Attribute Details
#fifo ⇒ Object
Returns the value of attribute fifo
59 60 61 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 59 def fifo @fifo end |
#last_duration ⇒ Object
Returns the value of attribute last_duration
59 60 61 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 59 def last_duration @last_duration end |
#max_duration ⇒ Object
Returns the value of attribute max_duration
59 60 61 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 59 def max_duration @max_duration end |
#mean ⇒ Object
Returns the value of attribute mean
59 60 61 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 59 def mean @mean end |
#min_duration ⇒ Object
Returns the value of attribute min_duration
59 60 61 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 59 def min_duration @min_duration end |
#ref ⇒ Object
Returns the value of attribute ref
59 60 61 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 59 def ref @ref end |
#sample_count ⇒ Object
Returns the value of attribute sample_count
59 60 61 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 59 def sample_count @sample_count end |
#sum_squares ⇒ Object
Returns the value of attribute sum_squares
59 60 61 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 59 def sum_squares @sum_squares end |
#total ⇒ Object
Returns the value of attribute total
59 60 61 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 59 def total @total end |
Instance Method Details
#mean_delta(old_mean, duration, new_count) ⇒ Object
88 89 90 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 88 def mean_delta(old_mean, duration, new_count) (duration - old_mean) / new_count end |
#sum_squares_delta(duration, old_mean, new_mean) ⇒ Object
92 93 94 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 92 def sum_squares_delta(duration, old_mean, new_mean) (duration - new_mean) * (duration - old_mean) end |
#to_s ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 96 def to_s ratio = total / (Time.now - ref) sd = Math.sqrt(variance) format( "max=%<max>.3f min=%<min>.3f total=%<ratio>i%% " \ "mean=%<mean>.3f sd=%<sd>.3f", max: max_duration, min: min_duration, ratio: (ratio * 100).round, mean: mean, sd: sd ) end |
#update(duration) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 64 def update(duration) self.total += duration update_min_max(duration) update_statistics(duration, sample_count + 1) self.sample_count = sample_count + 1 self.last_duration = duration end |
#update_min_max(duration) ⇒ Object
76 77 78 79 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 76 def update_min_max(duration) self.min_duration = duration if min_duration > duration self.max_duration = duration if max_duration < duration end |
#update_statistics(duration, new_count) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 81 def update_statistics(duration, new_count) old_mean = mean new_mean = old_mean + mean_delta(old_mean, duration, new_count) self.sum_squares += sum_squares_delta(duration, old_mean, new_mean) self.mean = new_mean end |
#variance ⇒ Object
72 73 74 |
# File 'lib/roby/event_logging/io_event_logger.rb', line 72 def variance sum_squares / sample_count end |