pull/18881/head
Na-Na Pang 6 years ago
parent c905f76a5b
commit 714e13b426
  1. 2
      test/cpp/microbenchmarks/callback_streaming_ping_pong.h
  2. 5
      test/cpp/microbenchmarks/callback_test_service.cc
  3. 8
      test/cpp/microbenchmarks/callback_test_service.h

@ -54,12 +54,10 @@ static void BM_CallbackBidiStreaming(benchmark::State& state) {
std::mutex mu;
std::condition_variable cv;
bool done = false;
gpr_log(GPR_INFO, "big enter");
BidiClient* test =
new BidiClient(state, stub_.get(), &request, &response, mu, cv, done);
test->StartNewRpc();
test->Await();
gpr_log(GPR_INFO, "big exit");
}
fixture->Finish(state);
fixture.reset();

@ -71,7 +71,6 @@ CallbackStreamingTestService::BidiStream() {
kServerFinishAfterNReads, context->client_metadata(), 0);
message_size_ = GetIntValueFromMetadata(kServerMessageSize,
context->client_metadata(), 0);
gpr_log(GPR_INFO, "server enter n reads %d", server_write_last_);
StartRead(&request_);
}
void OnDone() override {
@ -84,17 +83,14 @@ CallbackStreamingTestService::BidiStream() {
return;
}
num_msgs_read_++;
gpr_log(GPR_INFO, "server read %d", num_msgs_read_);
if (message_size_ > 0) {
response_.set_message(std::string(message_size_, 'a'));
} else {
response_.set_message("");
}
if (num_msgs_read_ < server_write_last_) {
gpr_log(GPR_INFO, "server start write %d", num_msgs_read_);
StartWrite(&response_);
} else {
gpr_log(GPR_INFO, "server last write %d", num_msgs_read_);
StartWriteLast(&response_, WriteOptions());
}
}
@ -102,7 +98,6 @@ CallbackStreamingTestService::BidiStream() {
if (!ok) {
return;
}
gpr_log(GPR_INFO, "server write %d", num_msgs_read_);
if (num_msgs_read_ < server_write_last_) {
StartRead(&request_);
} else {

@ -58,7 +58,6 @@ class BidiClient
mu_{mu},
cv_{cv},
done_(done) {
gpr_log(GPR_INFO, "client enter");
msgs_size_ = state.range(0);
msgs_to_send_ = state.range(1);
cli_ctx_ = new ClientContext();
@ -87,13 +86,10 @@ class BidiClient
void OnDone(const Status& s) override {
GPR_ASSERT(s.ok());
if (state_.KeepRunning()) {
count++;
gpr_log(GPR_INFO, "client start %d rpc", count);
BidiClient* test =
new BidiClient(state_, stub_, request_, response_, mu_, cv_, done_);
test->StartNewRpc();
} else {
gpr_log(GPR_INFO, "client done");
std::unique_lock<std::mutex> l(mu_);
done_ = true;
cv_.notify_one();
@ -109,12 +105,9 @@ class BidiClient
}
void StartNewRpc() {
gpr_log(GPR_INFO, "%d rpc start", count);
stub_->experimental_async()->BidiStream(cli_ctx_, this);
gpr_log(GPR_INFO, "%d write start", count);
MaybeWrite();
StartCall();
gpr_log(GPR_INFO, "%d call start", count);
}
private:
@ -134,7 +127,6 @@ class BidiClient
int writes_complete_{0};
int msgs_to_send_;
int msgs_size_;
int count{0};
std::mutex& mu_;
std::condition_variable& cv_;
bool& done_;

Loading…
Cancel
Save