21 #ifndef TEST_CPP_MICROBENCHMARKS_FULLSTACK_STREAMING_PUMP_H
22 #define TEST_CPP_MICROBENCHMARKS_FULLSTACK_STREAMING_PUMP_H
26 #include <benchmark/benchmark.h>
29 #include "src/proto/grpc/testing/echo.grpc.pb.h"
40 static void*
tag(
intptr_t x) {
return reinterpret_cast<void*
>(
x); }
42 template <
class Fixture>
44 EchoTestService::AsyncService
service;
48 EchoRequest recv_request;
49 if (
state.range(0) > 0) {
57 std::unique_ptr<EchoTestService::Stub>
stub(
58 EchoTestService::NewStub(
fixture->channel()));
60 auto request_rw =
stub->AsyncBidiStream(&cli_ctx,
fixture->cq(),
tag(1));
61 int need_tags = (1 << 0) | (1 << 1);
67 int i =
static_cast<int>(
reinterpret_cast<intptr_t>(t));
69 need_tags &= ~(1 <<
i);
71 response_rw.
Read(&recv_request,
tag(0));
78 response_rw.
Read(&recv_request,
tag(0));
79 }
else if (t ==
tag(1)) {
86 request_rw->WritesDone(
tag(1));
87 need_tags = (1 << 0) | (1 << 1);
90 int i =
static_cast<int>(
reinterpret_cast<intptr_t>(t));
92 need_tags &= ~(1 <<
i);
96 request_rw->Finish(&final_status,
tag(1));
97 need_tags = (1 << 0) | (1 << 1);
100 int i =
static_cast<int>(
reinterpret_cast<intptr_t>(t));
102 need_tags &= ~(1 <<
i);
111 template <
class Fixture>
113 EchoTestService::AsyncService
service;
116 EchoResponse send_response;
117 EchoResponse recv_response;
118 if (
state.range(0) > 0) {
126 std::unique_ptr<EchoTestService::Stub>
stub(
127 EchoTestService::NewStub(
fixture->channel()));
129 auto request_rw =
stub->AsyncBidiStream(&cli_ctx,
fixture->cq(),
tag(1));
130 int need_tags = (1 << 0) | (1 << 1);
136 int i =
static_cast<int>(
reinterpret_cast<intptr_t>(t));
138 need_tags &= ~(1 <<
i);
140 request_rw->Read(&recv_response,
tag(0));
143 response_rw.
Write(send_response,
tag(1));
147 request_rw->Read(&recv_response,
tag(0));
148 }
else if (t ==
tag(1)) {
156 need_tags = (1 << 0) | (1 << 1);
159 int i =
static_cast<int>(
reinterpret_cast<intptr_t>(t));
161 need_tags &= ~(1 <<
i);
171 #endif // TEST_CPP_MICROBENCHMARKS_FULLSTACK_FIXTURES_H