aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps/client_sync.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/qps/client_sync.cc')
-rw-r--r--test/cpp/qps/client_sync.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index c28dc91321..718698bfe1 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -32,6 +32,7 @@
*/
#include <cassert>
+#include <chrono>
#include <memory>
#include <mutex>
#include <string>
@@ -57,6 +58,7 @@
#include "test/cpp/qps/client.h"
#include "test/cpp/qps/qpstest.grpc.pb.h"
#include "test/cpp/qps/histogram.h"
+#include "test/cpp/qps/interarrival.h"
#include "test/cpp/qps/timer.h"
namespace grpc {
@@ -68,11 +70,19 @@ class SynchronousClient : public Client {
num_threads_ =
config.outstanding_rpcs_per_channel() * config.client_channels();
responses_.resize(num_threads_);
+ SetupLoadTest(config, num_threads_);
}
virtual ~SynchronousClient(){};
protected:
+ void WaitToIssue(int thread_idx) {
+ grpc_time next_time;
+ if (NextIssueTime(thread_idx, &next_time)) {
+ std::this_thread::sleep_until(next_time);
+ }
+ }
+
size_t num_threads_;
std::vector<SimpleResponse> responses_;
};
@@ -86,13 +96,14 @@ class SynchronousUnaryClient GRPC_FINAL : public SynchronousClient {
~SynchronousUnaryClient() { EndThreads(); }
bool ThreadFunc(Histogram* histogram, size_t thread_idx) GRPC_OVERRIDE {
+ WaitToIssue(thread_idx);
auto* stub = channels_[thread_idx % channels_.size()].get_stub();
double start = Timer::Now();
grpc::ClientContext context;
grpc::Status s =
stub->UnaryCall(&context, request_, &responses_[thread_idx]);
histogram->Add((Timer::Now() - start) * 1e9);
- return s.IsOk();
+ return s.ok();
}
};
@@ -113,12 +124,13 @@ class SynchronousStreamingClient GRPC_FINAL : public SynchronousClient {
for (auto stream = stream_.begin(); stream != stream_.end(); stream++) {
if (*stream) {
(*stream)->WritesDone();
- EXPECT_TRUE((*stream)->Finish().IsOk());
+ EXPECT_TRUE((*stream)->Finish().ok());
}
}
}
bool ThreadFunc(Histogram* histogram, size_t thread_idx) GRPC_OVERRIDE {
+ WaitToIssue(thread_idx);
double start = Timer::Now();
if (stream_[thread_idx]->Write(request_) &&
stream_[thread_idx]->Read(&responses_[thread_idx])) {