From d4eefad5874a31ef7064c7a63c167bf034a0819a Mon Sep 17 00:00:00 2001 From: han J <89577994+owny990312@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:31:41 +0800 Subject: [PATCH] minor modification to benchmark (#100) Co-authored-by: hanjun --- .../benchmark_subscriber_module.cc | 4 ++-- .../benchmark_rpc_client_module.cc | 2 +- src/examples/py/pb_chn_bench/benchmark_subscriber_module.py | 2 +- src/examples/py/pb_rpc_bench/benchmark_rpc_client_module.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/examples/cpp/pb_chn/module/benchmark_subscriber_module/benchmark_subscriber_module.cc b/src/examples/cpp/pb_chn/module/benchmark_subscriber_module/benchmark_subscriber_module.cc index 0efef23bb..f3e32e258 100644 --- a/src/examples/cpp/pb_chn/module/benchmark_subscriber_module/benchmark_subscriber_module.cc +++ b/src/examples/cpp/pb_chn/module/benchmark_subscriber_module/benchmark_subscriber_module.cc @@ -175,7 +175,7 @@ void BenchmarkSubscriberModule::Evaluate() const { size_t recv_count = statistics_array.size(); - double loss_rate = static_cast(send_count - recv_count) / send_count; + double loss_rate = static_cast(send_count - recv_count) / send_count * 100.0; std::sort(statistics_array.begin(), statistics_array.end()); @@ -195,7 +195,7 @@ msg size: {} bytes msg count per topic: {} send count : {} recv count: {} -loss rate: {} +loss rate: {} % min latency: {} us max latency: {} us avg latency: {} us diff --git a/src/examples/cpp/pb_rpc/module/benchmark_rpc_client_module/benchmark_rpc_client_module.cc b/src/examples/cpp/pb_rpc/module/benchmark_rpc_client_module/benchmark_rpc_client_module.cc index a657ddfea..c312888c1 100644 --- a/src/examples/cpp/pb_rpc/module/benchmark_rpc_client_module/benchmark_rpc_client_module.cc +++ b/src/examples/cpp/pb_rpc/module/benchmark_rpc_client_module/benchmark_rpc_client_module.cc @@ -232,7 +232,7 @@ co::Task BenchmarkRpcClientModule::StartSinglePlan(uint32_t plan_id, Bench uint64_t correct_count = gather_vec.size(); uint64_t total_count = plan.msg_count * plan.parallel; - double error_rate = static_cast(total_count - correct_count) / total_count; + double error_rate = static_cast(total_count - correct_count) / total_count * 100; double qps = (total_count * 1000.0) / total_time_ms; std::sort(gather_vec.begin(), gather_vec.end()); diff --git a/src/examples/py/pb_chn_bench/benchmark_subscriber_module.py b/src/examples/py/pb_chn_bench/benchmark_subscriber_module.py index 65e53d37b..24d165f61 100644 --- a/src/examples/py/pb_chn_bench/benchmark_subscriber_module.py +++ b/src/examples/py/pb_chn_bench/benchmark_subscriber_module.py @@ -168,7 +168,7 @@ class BenchmarkSubscriber(aimrt_py.ModuleBase): result_str += f"\nmsg count per topic: {self.cur_bench_plan.send_num}" result_str += f"\nsend count: {send_count}" result_str += f"\nrecv count: {recv_count}" - result_str += f"\nloss rate: {loss_rate:.2f}" + result_str += f"\nloss rate: {loss_rate:.2f} % " result_str += f"\nmin latency: {min_latency:.3f} us" result_str += f"\nmax latency: {max_latency:.3f} us" result_str += f"\navg latency: {avg_latency:.3f} us" diff --git a/src/examples/py/pb_rpc_bench/benchmark_rpc_client_module.py b/src/examples/py/pb_rpc_bench/benchmark_rpc_client_module.py index 573c6e436..c8fdd9601 100644 --- a/src/examples/py/pb_rpc_bench/benchmark_rpc_client_module.py +++ b/src/examples/py/pb_rpc_bench/benchmark_rpc_client_module.py @@ -168,7 +168,7 @@ class BenchmarkRpcClientModule(aimrt_py.ModuleBase): correct_count = len(self.perf_data) total_count = plan['parallel'] * plan['msg_count'] - error_rate = (total_count - correct_count) / total_count + error_rate = (total_count - correct_count) / total_count * 100.0 qps = (total_count * 1000.0) / total_time_ms min_latency = self.perf_data[0]