Changes based on comment

pull/18881/head
Na-Na Pang 6 years ago
parent b028141f01
commit e70d507abe
  1. 67
      test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc
  2. 4
      test/cpp/microbenchmarks/callback_streaming_ping_pong.h
  3. 9
      test/cpp/microbenchmarks/callback_test_service.cc
  4. 6
      test/cpp/microbenchmarks/callback_unary_ping_pong.h

@ -34,12 +34,15 @@ auto& force_library_initialization = Library::get();
static void SweepSizesArgs(benchmark::internal::Benchmark* b) {
b->Args({0, 0});
for (int i = 1; i <= 128 * 1024 * 1024; i *= 8) {
// First argument is the message size of request
// Second argument is the message size of response
b->Args({i, 0});
b->Args({0, i});
b->Args({i, i});
}
}
// Unary ping pong with different message size of request and response
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
NoOpMutator)
->Apply(SweepSizesArgs);
@ -52,6 +55,8 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator,
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, MinInProcessCHTTP2, NoOpMutator,
NoOpMutator)
->Apply(SweepSizesArgs);
// Client context with different metadata
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess,
Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
->Args({0, 0});
@ -72,15 +77,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess,
Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess,
Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
->Args({0, 0});
@ -90,18 +86,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess,
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess,
Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
->Args({0, 0});
@ -122,15 +106,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
->Args({0, 0});
@ -140,6 +115,38 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2,
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
->Args({0, 0});
// Server context with different metadata
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
->Args({0, 0});

@ -61,8 +61,8 @@ static void BM_CallbackBidiStreaming(benchmark::State& state) {
}
fixture->Finish(state);
fixture.reset();
state.SetBytesProcessed(2 * state.range(0) * state.iterations() *
state.range(1));
state.SetBytesProcessed(2 * message_size * max_ping_pongs
* state.iterations());
}
} // namespace testing

@ -64,14 +64,6 @@ CallbackStreamingTestService::BidiStream() {
kServerFinishAfterNReads, context->client_metadata(), 0);
message_size_ = GetIntValueFromMetadata(kServerResponseStreamsToSend,
context->client_metadata(), 0);
// EchoRequest* request = new EchoRequest;
// if (message_size_ > 0) {
// request->set_message(std::string(message_size_, 'a'));
// } else {
// request->set_message("");
// }
//
// request_ = request;
StartRead(&request_);
on_started_done_ = true;
}
@ -80,7 +72,6 @@ CallbackStreamingTestService::BidiStream() {
void OnReadDone(bool ok) override {
if (ok) {
num_msgs_read_++;
// gpr_log(GPR_INFO, "recv msg %s", request_.message().c_str());
if (message_size_ > 0) {
response_.set_message(std::string(message_size_, 'a'));
} else {

@ -38,6 +38,8 @@ namespace testing {
template <class Fixture, class ClientContextMutator, class ServerContextMutator>
static void BM_CallbackUnaryPingPong(benchmark::State& state) {
int request_msgs_size = state.range(0);
int response_msgs_size = state.range(1);
CallbackStreamingTestService service;
std::unique_ptr<Fixture> fixture(new Fixture(&service));
std::unique_ptr<EchoTestService::Stub> stub_(
@ -76,8 +78,8 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) {
}
fixture->Finish(state);
fixture.reset();
state.SetBytesProcessed(state.range(0) * state.iterations() +
state.range(1) * state.iterations());
state.SetBytesProcessed(request_msgs_size * state.iterations() +
response_msgs_size * state.iterations());
}
} // namespace testing
} // namespace grpc

Loading…
Cancel
Save