diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index 4af453740b4..1435246de21 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -232,10 +232,7 @@ grpc_cc_library( ], tags = ["no_windows"], deps = [ - "//:grpc++_unsecure", - "//src/proto/grpc/testing:echo_proto", - "//test/core/util:grpc_test_util_unsecure", - "//test/cpp/util:test_config", + ":helpers", "//test/cpp/util:test_util", ], ) diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 1c92af9c3e2..7861aa67780 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -54,10 +54,8 @@ static void BM_CallbackBidiStreaming(benchmark::State& state) { std::mutex mu; std::condition_variable cv; bool done = false; - BidiClient* test = - new BidiClient(&state, stub_.get(), &request, &response, - &mu, &cv, &done); - test->StartNewRpc(); + BidiClient test{&state, stub_.get(), &request, &response, &mu, &cv, &done}; + test.StartNewRpc(); std::unique_lock l(mu); while (!done) { cv.wait(l); diff --git a/test/cpp/microbenchmarks/callback_test_service.h b/test/cpp/microbenchmarks/callback_test_service.h index cdb8c79e234..0d371c4c740 100644 --- a/test/cpp/microbenchmarks/callback_test_service.h +++ b/test/cpp/microbenchmarks/callback_test_service.h @@ -60,10 +60,6 @@ class BidiClient done_(done) { msgs_size_ = state->range(0); msgs_to_send_ = state->range(1); - cli_ctx_ = new ClientContext(); - cli_ctx_->AddMetadata(kServerFinishAfterNReads, - grpc::to_string(msgs_to_send_)); - cli_ctx_->AddMetadata(kServerMessageSize, grpc::to_string(msgs_size_)); } void OnReadDone(bool ok) override { @@ -98,6 +94,10 @@ class BidiClient } void StartNewRpc() { + cli_ctx_ = new ClientContext(); + cli_ctx_->AddMetadata(kServerFinishAfterNReads, + grpc::to_string(msgs_to_send_)); + cli_ctx_->AddMetadata(kServerMessageSize, grpc::to_string(msgs_size_)); stub_->experimental_async()->BidiStream(cli_ctx_, this); MaybeWrite(); StartCall();