Skip to content

Commit

Permalink
Allow specifying warmup, benchmark times
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Apr 9, 2015
1 parent fb0edb8 commit b9de09f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 5 additions & 3 deletions test/cpp/qps/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ static vector<string> get_hosts(const string& name) {
ScenarioResult RunScenario(const ClientConfig& initial_client_config,
size_t num_clients,
const ServerConfig& server_config,
size_t num_servers) {
size_t num_servers,
int warmup_seconds,
int benchmark_seconds) {
// ClientContext allocator (all are destroyed at scope exit)
list<ClientContext> contexts;
auto alloc_context = [&contexts]() {
Expand Down Expand Up @@ -146,7 +148,7 @@ ScenarioResult RunScenario(const ClientConfig& initial_client_config,
// Let everything warmup
gpr_log(GPR_INFO, "Warming up");
gpr_timespec start = gpr_now();
gpr_sleep_until(gpr_time_add(start, gpr_time_from_seconds(5)));
gpr_sleep_until(gpr_time_add(start, gpr_time_from_seconds(warmup_seconds)));

// Start a run
gpr_log(GPR_INFO, "Starting");
Expand All @@ -171,7 +173,7 @@ ScenarioResult RunScenario(const ClientConfig& initial_client_config,

// Wait some time
gpr_log(GPR_INFO, "Running");
gpr_sleep_until(gpr_time_add(start, gpr_time_from_seconds(15)));
gpr_sleep_until(gpr_time_add(start, gpr_time_from_seconds(benchmark_seconds)));

// Finish a run
ScenarioResult result;
Expand Down
5 changes: 4 additions & 1 deletion test/cpp/qps/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ struct ScenarioResult {
ScenarioResult RunScenario(const grpc::testing::ClientConfig& client_config,
size_t num_clients,
const grpc::testing::ServerConfig& server_config,
size_t num_servers);
size_t num_servers,
int warmup_seconds,
int benchmark_seconds);

} // namespace testing
} // namespace grpc

Expand Down
8 changes: 6 additions & 2 deletions test/cpp/qps/qps_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
DEFINE_int32(num_clients, 1, "Number of client binaries");
DEFINE_int32(num_servers, 1, "Number of server binaries");

DEFINE_int32(warmup_seconds, 5, "Warmup time (in seconds)");
DEFINE_int32(benchmark_seconds, 30, "Benchmark time (in seconds)");

// Common config
DEFINE_bool(enable_ssl, false, "Use SSL");
DEFINE_string(rpc_type, "UNARY", "Type of RPC: UNARY or STREAMING");
Expand Down Expand Up @@ -98,8 +101,9 @@ int main(int argc, char** argv) {
server_config.set_threads(FLAGS_server_threads);
server_config.set_enable_ssl(FLAGS_enable_ssl);

auto result = RunScenario(client_config, FLAGS_num_clients, server_config,
FLAGS_num_servers);
auto result = RunScenario(client_config, FLAGS_num_clients,
server_config, FLAGS_num_servers,
FLAGS_warmup_seconds, FLAGS_benchmark_seconds);

gpr_log(GPR_INFO, "QPS: %.1f",
result.latencies.Count() /
Expand Down

0 comments on commit b9de09f

Please sign in to comment.