aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-09-14 08:37:10 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-09-14 08:37:10 -0700
commit9e1c2d2358117d0b9afad5da19df77e23ae17dc1 (patch)
tree922385f8c057f70d22ef02e0e92cbbdaa41aa3d8 /test/cpp/qps
parent531976a6d46602452028811583710244f676795a (diff)
Dont start requests until all clients have gotten connected
Diffstat (limited to 'test/cpp/qps')
-rw-r--r--test/cpp/qps/client.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index 86543e99fb..c8809cbc5b 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -129,13 +129,17 @@ class HistogramEntry GRPC_FINAL {
class Client {
public:
- Client() : timer_(new UsageTimer), interarrival_timer_() {}
+ Client() : timer_(new UsageTimer), interarrival_timer_() {
+ gpr_event_init(&start_requests_);
+ }
virtual ~Client() {}
ClientStats Mark(bool reset) {
Histogram latencies;
UsageTimer::Result timer_result;
+ MaybeStartRequests();
+
// avoid std::vector for old compilers that expect a copy constructor
if (reset) {
Histogram* to_merge = new Histogram[threads_.size()];
@@ -189,7 +193,10 @@ class Client {
}
}
- void EndThreads() { threads_.clear(); }
+ void EndThreads() {
+ MaybeStartRequests();
+ threads_.clear();
+ }
virtual void DestroyMultithreading() = 0;
virtual bool ThreadFunc(HistogramEntry* histogram, size_t thread_idx) = 0;
@@ -265,6 +272,13 @@ class Client {
Thread& operator=(const Thread&);
void ThreadFunc() {
+ while (!gpr_event_wait(
+ &client_->start_requests_,
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(1, GPR_TIMESPAN)))) {
+ gpr_log(GPR_INFO, "Waiting for benchmark to start");
+ }
+
for (;;) {
// run the loop body
HistogramEntry entry;
@@ -302,6 +316,16 @@ class Client {
size_t threads_remaining_;
std::condition_variable threads_complete_;
+ gpr_event start_requests_;
+ bool started_requests_;
+
+ void MaybeStartRequests() {
+ if (!started_requests_) {
+ started_requests_ = true;
+ gpr_event_set(&start_requests_, (void*)1);
+ }
+ }
+
void CompleteThread() {
std::lock_guard<std::mutex> g(thread_completion_mu_);
threads_remaining_--;