• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. _module-pw_rpc-benchmark:
2
3===================
4pw_rpc Benchmarking
5===================
6pw_rpc provides tools for stress testing and benchmarking a Pigweed RPC
7deployment and the transport it is running over. Two components are included:
8
9* The pw.rpc.Benchmark service and its implementation.
10* A Python module that runs tests using the Benchmark service.
11
12------------------------
13pw.rpc.Benchmark service
14------------------------
15The Benchmark service provides a low-level RPC service for sending data between
16the client and server. The service is defined in ``pw_rpc/benchmark.proto``.
17
18A raw RPC implementation of the benchmark service is provided. This
19implementation is suitable for use in any system with pw_rpc. To access this
20service, add a dependency on ``"$dir_pw_rpc:benchmark"`` in GN or
21``pw_rpc.benchmark`` in CMake. Then, include the service
22(``#include "pw_rpc/benchmark.h"``), instantiate it, and register it with your
23RPC server, like any other RPC service.
24
25The Benchmark service was designed with the Python-based benchmarking tools in
26mind, but it may be used directly to test basic RPC functionality. The service
27is well suited for use in automated integration tests or in an interactive
28console.
29
30Benchmark service
31==================
32.. literalinclude:: benchmark.proto
33  :language: protobuf
34  :lines: 14-
35
36Example
37=======
38.. code-block:: c++
39
40  #include "pw_rpc/benchmark.h"
41  #include "pw_rpc/server.h"
42
43  constexpr pw::rpc::Channel kChannels[] = { /* ... */ };
44  static pw::rpc::Server server(kChannels);
45
46  static pw::rpc::BenchmarkService benchmark_service;
47
48  void RegisterServices() {
49    server.RegisterService(benchmark_service);
50  }
51
52