forked from AimRT/AimRT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add aimrt_py benchmark publisher and subscriber applications (A…
…imRT#28) * feat: add aimrt_py benchmark publisher and subscriber applications Introduce new benchmark publisher and subscriber modules, enabling performance testing with custom configuration. Includes necessary YAML configuration files and scripts for simulation of message publishing and receiving. * style: correct message size formatting Update the log message to use "bytes" for clarity and consistency in reporting metrics. * feat: add python benchmark example and update dependencies Introduce an aimrt_py benchmark example for Python testing. Replace boost dependency with the standalone asio library to reduce overall dependencies and enhance configuration options for zenoh and mqtt. * feat: add aimrt_py channel benchmark example Introduce a new benchmark example for aimrt_py to enhance Python benchmarking capabilities and provide clearer insights into performance metrics. * format code * style: format loss rate output Remove the percentage symbol from the loss rate display for a cleaner presentation. * docs: update release notes for v0.9.0 Clarify new features, config options, and dependency changes, including the addition of the aimrt_py channel benchmark example and removal of boost dependencies in favor of asio. * docs: add benchmark example to Python interfaces section Include a new link for the pb_chn_bench example to enhance the documentation and provide users with more comprehensive usage scenarios. * docs: add README for protobuf channel benchmark example Provide instructions on setting up and running a Python channel benchmark using protobuf with HTTP backend. Include details on core modules, configuration, and execution steps to enhance usability and understanding. * docs: update installation instructions to link to quick start guide Enhance user experience by providing direct access to the installation guide for the `aimrt_py` package, improving clarity and reducing search time for new users. * docs: correct grpc reference in README Update the section title to accurately reflect the protocol being used, enhancing clarity for users.
- Loading branch information
1 parent
85ca6fb
commit 036bd5b
Showing
18 changed files
with
712 additions
and
11 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
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
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
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
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
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
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,34 @@ | ||
# protobuf channel benchmark | ||
|
||
|
||
一个基于 protobuf 协议与 http 后端的 python channel benchmark 示例,演示内容包括: | ||
- 如何在 python 中使用 protobuf 协议作为 channel 传输协议; | ||
- 如何基于 aimrt_py 注册模块的方式使用 Channel publish 和 subscribe 功能; | ||
- 如何使用 http 类型的 channel 后端; | ||
|
||
核心代码: | ||
- [benchmark.proto](../../../protocols/example/benchmark.proto) | ||
- [benchmark_publisher_module.py](./benchmark_publisher_module.py) | ||
- [benchmark_publisher_app.py](./benchmark_publisher_app.py) | ||
- [benchmark_subscriber_module.py](./benchmark_subscriber_module.py) | ||
- [benchmark_subscriber_app.py](./benchmark_subscriber_app.py) | ||
|
||
配置文件: | ||
- [benchmark_publisher_cfg.yaml](./cfg/benchmark_publisher_cfg.yaml) | ||
- [benchmark_subscriber_cfg.yaml](./cfg/benchmark_subscriber_cfg.yaml) | ||
|
||
|
||
运行方式(linux): | ||
- [安装 `aimrt_py` 包](../../../../document/sphinx-cn/tutorials/quick_start/installation_py.md); | ||
- 运行本目录下的[build_examples_py_pb_chn_bench.sh](./build_examples_py_pb_chn_bench.sh)脚本,生成协议桩代码文件; | ||
- 如果本地没有 protoc 或者 protoc 版本小于 3.20,请安装或升级 protoc,或直接修改脚本中的 `protoc_cmd` 变量指向合适的路径; | ||
- 运行本目录下的[start_benchmark_subscriber.sh](./start_benchmark_subscriber.sh)脚本,启动 subscriber; | ||
- 在新终端里运行本目录下的[start_benchmark_publisher.sh](./start_benchmark_publisher.sh)脚本,启动 publisher; | ||
- Benchmark 运行结束后会输出 benchmark 结果并自动结束进程; | ||
|
||
|
||
说明: | ||
- 此示例创建了以下两个模块: | ||
- `BenchmarkPublisherModule`:会在启动后根据配置好的 bench plan 向指定的 test_topic_xx 中发布类型为 `BenchmarkMsg` 的消息,每个 bench plan 前后会发送一个 `BenchmarkSignal` 类型的消息通知 subscriber 当前的 benchmark 状态,所有 bench plan 结束后会发送一个 `BenchmarkSignal` 类型的消息通知 subscriber 当前的 benchmark 结束; | ||
- `BenchmarkSubscriberModule`:会订阅 channel 中的 test_topic_xx 消息,并统计接收到的消息的延迟分布; | ||
- 此示例使用 http 类型的 channel 后端进行通信,请确保相关端口未被占用; |
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,61 @@ | ||
# Copyright (c) 2024 The AimRT Authors. | ||
# AimRT is licensed under Mulan PSL v2. | ||
|
||
import argparse | ||
import signal | ||
import sys | ||
import threading | ||
|
||
import aimrt_py | ||
import benchmark_publisher_module | ||
|
||
global_aimrt_core = None | ||
|
||
|
||
def signal_handler(sig, _): | ||
global global_aimrt_core | ||
|
||
if (global_aimrt_core and (sig == signal.SIGINT or sig == signal.SIGTERM)): | ||
global_aimrt_core.Shutdown() | ||
return | ||
|
||
sys.exit(0) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Example helloworld registration mode.') | ||
parser.add_argument('--cfg_file_path', type=str, default="", help='config file path') | ||
args = parser.parse_args() | ||
|
||
signal.signal(signal.SIGINT, signal_handler) | ||
signal.signal(signal.SIGTERM, signal_handler) | ||
|
||
print("AimRT start.") | ||
|
||
aimrt_core = aimrt_py.Core() | ||
|
||
global global_aimrt_core | ||
global_aimrt_core = aimrt_core | ||
|
||
module = benchmark_publisher_module.BenchmarkPublisher() | ||
aimrt_core.RegisterModule(module) | ||
|
||
core_options = aimrt_py.CoreOptions() | ||
core_options.cfg_file_path = args.cfg_file_path | ||
aimrt_core.Initialize(core_options) | ||
|
||
thread = threading.Thread(target=aimrt_core.Start) | ||
thread.start() | ||
|
||
while thread.is_alive(): | ||
thread.join(1.0) | ||
|
||
aimrt_core.Shutdown() | ||
|
||
global_aimrt_core = None | ||
|
||
print("AimRT exit.") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.