diff --git a/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc index c0a7054bf51..bcbde5db035 100644 --- a/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc @@ -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, 1>, NoOpMutator) ->Args({0, 0}); @@ -72,15 +77,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, Client_AddMetadata, 2>, NoOpMutator) ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); @@ -90,18 +86,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 100>) - ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); @@ -122,15 +106,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, Client_AddMetadata, 2>, NoOpMutator) ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); @@ -140,6 +115,38 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); + +// Server context with different metadata +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 100>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, Server_AddInitialMetadata, 1>) ->Args({0, 0}); diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 1710a754803..fc74e2757ba 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -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 diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc index caa734d90e8..eebf6e31241 100644 --- a/test/cpp/microbenchmarks/callback_test_service.cc +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -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 { diff --git a/test/cpp/microbenchmarks/callback_unary_ping_pong.h b/test/cpp/microbenchmarks/callback_unary_ping_pong.h index 01477e6402d..19449341747 100644 --- a/test/cpp/microbenchmarks/callback_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_unary_ping_pong.h @@ -38,6 +38,8 @@ namespace testing { template 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(new Fixture(&service)); std::unique_ptr 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