Class: Roby::EventLogging::IOEventLogger::TimepointGroupDisplay

Inherits:
Struct
  • Object
show all
Defined in:
lib/roby/event_logging/io_event_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#matcherObject

Returns the value of attribute matcher

Returns:

  • (Object)

    the current value of matcher



110
111
112
# File 'lib/roby/event_logging/io_event_logger.rb', line 110

def matcher
  @matcher
end

#skipObject

Returns the value of attribute skip

Returns:

  • (Object)

    the current value of skip



110
111
112
# File 'lib/roby/event_logging/io_event_logger.rb', line 110

def skip
  @skip
end

#start_timesObject

Returns the value of attribute start_times

Returns:

  • (Object)

    the current value of start_times



110
111
112
# File 'lib/roby/event_logging/io_event_logger.rb', line 110

def start_times
  @start_times
end

#statsObject

Returns the value of attribute stats

Returns:

  • (Object)

    the current value of stats



110
111
112
# File 'lib/roby/event_logging/io_event_logger.rb', line 110

def stats
  @stats
end

Instance Method Details

#message(name, _time) ⇒ Object

Return the statistics message for the given timepoint



145
146
147
148
149
150
151
152
153
# File 'lib/roby/event_logging/io_event_logger.rb', line 145

def message(name, _time)
    return unless (msg_stats = stats[name])

    format(
        TIMEPOINT_GROUP_FORMAT,
        name: name, duration: msg_stats.last_duration,
        stats: msg_stats.to_s
    )
end

#push(name, time) ⇒ Object

Add a group start event

The event is queued (hence "pushed") to properly handle recursive calls



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/roby/event_logging/io_event_logger.rb', line 117

def push(name, time)
    if skip > 0
        self.skip -= 1
        return
    end

    unless (msg_stats = stats[name])
        msg_stats = TimepointGroupStats.new(
            fifo: [], ref: Time.now, total: 0,
            min_duration: Float::INFINITY,
            max_duration: 0, sample_count: 0,
            mean: 0, sum_squares: 0
        )
        stats[name] = msg_stats
    end

    msg_stats.fifo.push(time)
end

#update(name, time) ⇒ Object

Add a group end event



137
138
139
140
141
142
# File 'lib/roby/event_logging/io_event_logger.rb', line 137

def update(name, time)
    return unless (msg_stats = stats[name])
    return unless (start_t = msg_stats.fifo.pop)

    msg_stats.update(time - start_t)
end