aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps/client.h
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2015-06-05 03:41:30 -0700
committerGravatar Vijay Pai <vpai@google.com>2015-06-05 03:41:30 -0700
commitcf3fb092cc595066e70f780a6ffc5c79f4531148 (patch)
treecb8e63031e983acbb6f595cdd03ad0567da0d0f8 /test/cpp/qps/client.h
parentc7de81e57ec4131993bd469a146739d74d564ab1 (diff)
clang-format
Diffstat (limited to 'test/cpp/qps/client.h')
-rw-r--r--test/cpp/qps/client.h49
1 files changed, 26 insertions, 23 deletions
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<std::chrono::high_resolution_clock::time_point> {
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_source> 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<RandomDist> 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<num_threads; i++) {
- next_time_.push_back(grpc_time_source::now() +
- std::chrono::duration_cast<grpc_time_source::duration>(interarrival_timer_(i)));
+ for (size_t i = 0; i < num_threads; i++) {
+ next_time_.push_back(
+ grpc_time_source::now() +
+ std::chrono::duration_cast<grpc_time_source::duration>(
+ 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<grpc_time_source::duration>(interarrival_timer_(thread_idx));
+ next_time_[thread_idx] +=
+ std::chrono::duration_cast<grpc_time_source::duration>(
+ interarrival_timer_(thread_idx));
return true;
}
}
-
+
private:
class Thread {
public: