9 def __init__(self, topic_name, duration, window_size=None):
30 print "waiting for", self.
duration,
"[sec]..." 40 rospy.signal_shutdown(
"finished measurement")
44 msg_size = reduce(
lambda a,b: a+b, map(
lambda x: len(x._buff), self.
msgs))
45 print "received", len(self.
msgs),
"messages for", d.to_sec(),
"[sec]" 46 print "size amount:\t", msg_size / 1000.0,
"[kB]" 47 print "size avg:\t", msg_size / 1000.0 / len(self.
msgs),
"[kB/msg]" 49 print "rate:\t\t", msg_size / 1000.0 / d.to_sec(),
"[kB/sec]" 51 if __name__ ==
'__main__':
52 p = optparse.OptionParser(usage=
"%prog [options] topic_name")
53 p.add_option(
"-w", dest=
"window_size", type=
"int", default=
None)
54 p.add_option(
"-d", dest=
"duration", type=
"int", default=5)
56 (opt, args) = p.parse_args(rospy.myargv())
61 rospy.init_node(
"topic_statistics")
63 window_size=opt.window_size,
64 duration=opt.duration)
def __init__(self, topic_name, duration, window_size=None)