From cf3fb092cc595066e70f780a6ffc5c79f4531148 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 5 Jun 2015 03:41:30 -0700 Subject: clang-format --- test/cpp/qps/client.h | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'test/cpp/qps/client.h') diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 7d75ed7d74..309e60d970 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -50,9 +50,10 @@ template <> class TimePoint { public: TimePoint(const std::chrono::high_resolution_clock::time_point& time) { - TimepointHR2Timespec(time, &time_); + TimepointHR2Timespec(time, &time_); } gpr_timespec raw_time() const { return time_; } + private: gpr_timespec time_; }; @@ -65,8 +66,8 @@ typedef std::chrono::time_point grpc_time; class Client { public: - explicit Client(const ClientConfig& config) : timer_(new Timer), - interarrival_timer_() { + explicit Client(const ClientConfig& config) + : timer_(new Timer), interarrival_timer_() { for (int i = 0; i < config.client_channels(); i++) { channels_.push_back(ClientChannelInfo( config.server_targets(i % config.server_targets_size()), config)); @@ -131,30 +132,29 @@ class Client { // Set up the load distribution based on the number of threads if (config.load_type() == CLOSED_LOOP) { closed_loop_ = true; - } - else { + } else { closed_loop_ = false; std::unique_ptr random_dist; auto& load = config.load_params(); switch (config.load_type()) { case POISSON: - random_dist.reset - (new ExpDist(load.poisson().offered_load()/num_threads)); + random_dist.reset( + new ExpDist(load.poisson().offered_load() / num_threads)); break; case UNIFORM: - random_dist.reset - (new UniformDist(load.uniform().interarrival_lo()*num_threads, - load.uniform().interarrival_hi()*num_threads)); + random_dist.reset( + new UniformDist(load.uniform().interarrival_lo() * num_threads, + load.uniform().interarrival_hi() * num_threads)); break; case DETERMINISTIC: - random_dist.reset - (new DetDist(num_threads/load.determ().offered_load())); + random_dist.reset( + new DetDist(num_threads / load.determ().offered_load())); break; case PARETO: - random_dist.reset - (new ParetoDist(load.pareto().interarrival_base()*num_threads, - load.pareto().alpha())); + random_dist.reset( + new ParetoDist(load.pareto().interarrival_base() * num_threads, + load.pareto().alpha())); break; default: GPR_ASSERT(false); @@ -162,23 +162,26 @@ class Client { } interarrival_timer_.init(*random_dist, num_threads); - for (size_t i = 0; i(interarrival_timer_(i))); + for (size_t i = 0; i < num_threads; i++) { + next_time_.push_back( + grpc_time_source::now() + + std::chrono::duration_cast( + interarrival_timer_(i))); } } } - bool NextIssueTime(int thread_idx, grpc_time *time_delay) { + bool NextIssueTime(int thread_idx, grpc_time* time_delay) { if (closed_loop_) { return false; - } - else { + } else { *time_delay = next_time_[thread_idx]; - next_time_[thread_idx] += std::chrono::duration_cast(interarrival_timer_(thread_idx)); + next_time_[thread_idx] += + std::chrono::duration_cast( + interarrival_timer_(thread_idx)); return true; } } - + private: class Thread { public: -- cgit v1.2.3