-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(autoware_debug_tools): add system performance plotter (#91)
* feat(autoware_debug_tools): add system performance plotter Signed-off-by: Takayuki Murooka <[email protected]> * update README Signed-off-by: Takayuki Murooka <[email protected]> * fix README.md Signed-off-by: Takayuki Murooka <[email protected]> --------- Signed-off-by: Takayuki Murooka <[email protected]>
- Loading branch information
1 parent
d5eae1a
commit 8c281ae
Showing
9 changed files
with
446 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
52 changes: 52 additions & 0 deletions
52
...autoware_debug_tools/autoware_debug_tools/system_performance_plotter/cpu_usage_plotter.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from tier4_debug_msgs.msg import SystemUsageArray | ||
|
||
from .system_performance_plotter_base import PREDEFINED_COMPONENT_NAMES | ||
from .system_performance_plotter_base import SystemPerformancePlotterBase | ||
from .system_performance_plotter_base import create_common_argment | ||
|
||
|
||
class CpuUsagePlotter(SystemPerformancePlotterBase): | ||
def check_topic(self, topic_name): | ||
if self.grep_topic_name is not None and self.grep_topic_name not in topic_name: | ||
return False | ||
if "/system_usage" not in topic_name: | ||
return False | ||
return True | ||
|
||
def update_metrics_func(self, topic_name, data, date_time): | ||
if not isinstance(data, SystemUsageArray): | ||
return | ||
|
||
for system_usage in data.system_usage: | ||
if self.component_name == "all": | ||
# all | ||
pass | ||
elif self.component_name not in PREDEFINED_COMPONENT_NAMES: | ||
# others (other than PREDEFINED_COMPONENT_NAMES) | ||
if system_usage.name.split("/")[0] in PREDEFINED_COMPONENT_NAMES: | ||
continue | ||
elif system_usage.name.split("/")[0] != self.component_name: | ||
# specific component | ||
continue | ||
|
||
if system_usage.name not in self.stamp_and_metrics: | ||
self.stamp_and_metrics[system_usage.name] = [] | ||
self.max_metrics[system_usage.name] = 0.0 | ||
|
||
cpu_usage = system_usage.cpu_usage | ||
self.stamp_and_metrics[system_usage.name].append([date_time, cpu_usage]) | ||
self.max_metrics[system_usage.name] = max( | ||
self.max_metrics[system_usage.name], cpu_usage | ||
) | ||
|
||
|
||
def main(): | ||
args = create_common_argment(100) | ||
plotter = CpuUsagePlotter(args, "CPU Usage [%]", "_cpu_usage") | ||
plotter.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
52 changes: 52 additions & 0 deletions
52
...oware_debug_tools/autoware_debug_tools/system_performance_plotter/memory_usage_plotter.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from tier4_debug_msgs.msg import SystemUsageArray | ||
|
||
from .system_performance_plotter_base import PREDEFINED_COMPONENT_NAMES | ||
from .system_performance_plotter_base import SystemPerformancePlotterBase | ||
from .system_performance_plotter_base import create_common_argment | ||
|
||
|
||
class MemoryUsagePlotter(SystemPerformancePlotterBase): | ||
def check_topic(self, topic_name): | ||
if self.grep_topic_name is not None and self.grep_topic_name not in topic_name: | ||
return False | ||
if "/system_usage" not in topic_name: | ||
return False | ||
return True | ||
|
||
def update_metrics_func(self, topic_name, data, date_time): | ||
if not isinstance(data, SystemUsageArray): | ||
return | ||
|
||
for system_usage in data.system_usage: | ||
if self.component_name == "all": | ||
# all | ||
pass | ||
elif self.component_name not in PREDEFINED_COMPONENT_NAMES: | ||
# others (other than PREDEFINED_COMPONENT_NAMES) | ||
if system_usage.name.split("/")[0] in PREDEFINED_COMPONENT_NAMES: | ||
continue | ||
elif system_usage.name.split("/")[0] != self.component_name: | ||
# specific component | ||
continue | ||
|
||
if system_usage.name not in self.stamp_and_metrics: | ||
self.stamp_and_metrics[system_usage.name] = [] | ||
self.max_metrics[system_usage.name] = 0.0 | ||
|
||
memory_usage = system_usage.memory_usage / 1024**2 | ||
self.stamp_and_metrics[system_usage.name].append([date_time, memory_usage]) | ||
self.max_metrics[system_usage.name] = max( | ||
self.max_metrics[system_usage.name], memory_usage | ||
) | ||
|
||
|
||
def main(): | ||
args = create_common_argment() | ||
plotter = MemoryUsagePlotter(args, "Memory Usage [MiB]", "_memory_usage") | ||
plotter.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
51 changes: 51 additions & 0 deletions
51
...re_debug_tools/autoware_debug_tools/system_performance_plotter/processing_time_plotter.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from tier4_debug_msgs.msg import Float64Stamped | ||
|
||
from .system_performance_plotter_base import PREDEFINED_COMPONENT_NAMES | ||
from .system_performance_plotter_base import SystemPerformancePlotterBase | ||
from .system_performance_plotter_base import create_common_argment | ||
|
||
|
||
class ProcessingTimePlotter(SystemPerformancePlotterBase): | ||
def check_topic(self, topic_name): | ||
if self.grep_topic_name is not None and self.grep_topic_name not in topic_name: | ||
return False | ||
if "/processing_time_ms" not in topic_name: | ||
return False | ||
|
||
if self.component_name == "all": | ||
# all | ||
pass | ||
elif self.component_name in PREDEFINED_COMPONENT_NAMES: | ||
# specific component | ||
if f"/{self.component_name}/" not in topic_name: | ||
return False | ||
else: | ||
# others (other than PREDEFINED_COMPONENT_NAMES) | ||
for predefined_component_name in PREDEFINED_COMPONENT_NAMES: | ||
if f"/{predefined_component_name}/" in topic_name: | ||
return False | ||
return True | ||
|
||
def update_metrics_func(self, topic_name, data, date_time): | ||
if not isinstance(data, Float64Stamped): | ||
return | ||
|
||
if topic_name not in self.stamp_and_metrics: | ||
self.stamp_and_metrics[topic_name] = [] | ||
self.max_metrics[topic_name] = 0.0 | ||
|
||
processing_time_ms = data.data | ||
self.stamp_and_metrics[topic_name].append([date_time, processing_time_ms]) | ||
self.max_metrics[topic_name] = max(self.max_metrics[topic_name], processing_time_ms) | ||
|
||
|
||
def main(): | ||
args = create_common_argment(100) | ||
plotter = ProcessingTimePlotter(args, "Processing Time [ms]", "_processing_time") | ||
plotter.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.