Created
April 1, 2020 18:08
-
-
Save clalancette/dfaee6948105bd1f781bbf151dc60a3c to your computer and use it in GitHub Desktop.
Python3 script to parse pc_pipe_times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bisect | |
| import copy | |
| import statistics | |
| import sys | |
| if len(sys.argv) != 2: | |
| print("Usage: %s <file>" % (sys.argv[0])) | |
| sys.exit(1) | |
| total_time_ms_list = [] | |
| times_tuple = { | |
| 'start': None, | |
| 'camera': None, | |
| 'image_filter_right': None, | |
| 'image_filter_left': None, | |
| 'disparity': None, | |
| 'pointcloud_sub': None, | |
| 'pointcloud_pub': None, | |
| 'topic_echo': None, | |
| } | |
| longest_time_tuple = {} | |
| with open(sys.argv[1], 'r') as infp: | |
| for line in infp: | |
| split = line.split(',') | |
| if len(split) != 2: | |
| continue | |
| name = split[0].strip() | |
| time_ms = int(split[1].strip()) | |
| if name == '"ROS2TOPIC PUB"': | |
| if times_tuple['start'] is not None: | |
| print("Lost data! Start time was %d" % (times_tuple['start'])) | |
| times_tuple['start'] = time_ms | |
| start_time_ms = time_ms | |
| elif name == '"CAMERA CONTROLLER SUB"': | |
| times_tuple['camera'] = time_ms | |
| elif name == '"IMAGE_FILTER_RIGHT SUB"': | |
| times_tuple['image_filter_right'] = time_ms | |
| elif name == '"IMAGE_FILTER_LEFT SUB"': | |
| times_tuple['image_filter_left'] = time_ms | |
| elif name == '"DISPARITY SUB"': | |
| times_tuple['disparity'] = time_ms | |
| elif name == '"POINTCLOUD SUB"': | |
| times_tuple['pointcloud_sub'] = time_ms | |
| elif name == '"POINTCLOUD PUB"': | |
| times_tuple['pointcloud_pub'] = time_ms | |
| elif name == '"ROS2TOPIC ECHO"': | |
| times_tuple['topic_echo'] = time_ms | |
| if times_tuple['start'] is not None: | |
| total_time_ms = times_tuple['topic_echo'] - times_tuple['start'] | |
| bisect.insort_left(total_time_ms_list, total_time_ms) | |
| if total_time_ms >= total_time_ms_list[-1]: | |
| longest_time_tuple = copy.deepcopy(times_tuple) | |
| times_tuple['start'] = None | |
| times_tuple['camera'] = None | |
| times_tuple['image_filter_right'] = None | |
| times_tuple['image_filter_left'] = None | |
| times_tuple['disparity'] = None | |
| times_tuple['pointcloud_sub'] = None | |
| times_tuple['pointcloud_pub'] = None | |
| times_tuple['topic_echo'] = None | |
| else: | |
| # Unknown name, skip | |
| print("Unknown name '%s', skipping" % (name)) | |
| continue | |
| #total_time_ms_list.sort() | |
| print("Total complete pipeline passes: %d" % (len(total_time_ms_list))) | |
| print("Average total time (ms): %d" % (sum(total_time_ms_list) / len(total_time_ms_list))) | |
| print("Median total time (ms): %d" % (statistics.median(total_time_ms_list))) | |
| print("Minimum total time (ms): %d" % (total_time_ms_list[0])) | |
| print("Maximum total time (ms): %d" % (total_time_ms_list[-1])) | |
| print(" start -> camera_controller: %d ms" % (longest_time_tuple['camera'] - longest_time_tuple['start'])) | |
| print(" camera_controller -> image_filter: %d ms" % (longest_time_tuple['image_filter_right'] - longest_time_tuple['camera'])) | |
| print(" image_filter -> disparity: %d ms" % (longest_time_tuple['disparity'] - longest_time_tuple['image_filter_right'])) | |
| print(" disparity -> pointcloud sub: %d ms" % (longest_time_tuple['pointcloud_sub'] - longest_time_tuple['disparity'])) | |
| print(" pointcloud sub -> pointcloud pub: %d ms" % (longest_time_tuple['pointcloud_pub'] - longest_time_tuple['pointcloud_sub'])) | |
| print(" pointcloud pub -> ros2topic echo: %d ms" % (longest_time_tuple['topic_echo'] - longest_time_tuple['pointcloud_pub'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment