diff options
Diffstat (limited to 'test/cpp/qps')
-rw-r--r-- | test/cpp/qps/async_streaming_ping_pong_test.cc | 10 | ||||
-rw-r--r-- | test/cpp/qps/async_unary_ping_pong_test.cc | 11 | ||||
-rw-r--r-- | test/cpp/qps/qps_driver.cc | 27 | ||||
-rw-r--r-- | test/cpp/qps/qps_test.cc | 9 | ||||
-rw-r--r-- | test/cpp/qps/report.cc | 50 | ||||
-rw-r--r-- | test/cpp/qps/report.h | 77 | ||||
-rw-r--r-- | test/cpp/qps/sync_streaming_ping_pong_test.cc | 10 | ||||
-rw-r--r-- | test/cpp/qps/sync_unary_ping_pong_test.cc | 9 |
8 files changed, 161 insertions, 42 deletions
diff --git a/test/cpp/qps/async_streaming_ping_pong_test.cc b/test/cpp/qps/async_streaming_ping_pong_test.cc index d4871c0ba1..411df4d32a 100644 --- a/test/cpp/qps/async_streaming_ping_pong_test.cc +++ b/test/cpp/qps/async_streaming_ping_pong_test.cc @@ -31,12 +31,15 @@ * */ +#include <set> + #include <grpc/support/log.h> #include <signal.h> #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -64,16 +67,17 @@ static void RunAsyncStreamingPingPong() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPS(*result); - ReportLatency(*result); + GetReporter()->ReportQPS(*result); + GetReporter()->ReportLatency(*result); } } // namespace testing } // namespace grpc int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + signal(SIGPIPE, SIG_IGN); grpc::testing::RunAsyncStreamingPingPong(); - return 0; } diff --git a/test/cpp/qps/async_unary_ping_pong_test.cc b/test/cpp/qps/async_unary_ping_pong_test.cc index 35f188c986..eda31b5744 100644 --- a/test/cpp/qps/async_unary_ping_pong_test.cc +++ b/test/cpp/qps/async_unary_ping_pong_test.cc @@ -31,12 +31,15 @@ * */ +#include <set> + #include <grpc/support/log.h> #include <signal.h> #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -64,16 +67,16 @@ static void RunAsyncUnaryPingPong() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPS(*result); - ReportLatency(*result); + GetReporter()->ReportQPS(*result); + GetReporter()->ReportLatency(*result); } - } // namespace testing } // namespace grpc int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); signal(SIGPIPE, SIG_IGN); - grpc::testing::RunAsyncUnaryPingPong(); + grpc::testing::RunAsyncUnaryPingPong(); return 0; } diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index 008830de4e..281e2e8119 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -31,12 +31,15 @@ * */ +#include <memory> +#include <set> + #include <gflags/gflags.h> #include <grpc/support/log.h> #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" -#include "test/cpp/util/test_config.h" +#include "test/cpp/util/benchmark_config.h" DEFINE_int32(num_clients, 1, "Number of client binaries"); DEFINE_int32(num_servers, 1, "Number of server binaries"); @@ -68,9 +71,10 @@ using grpc::testing::ServerType; using grpc::testing::RpcType; using grpc::testing::ResourceUsage; -int main(int argc, char** argv) { - grpc::testing::InitTest(&argc, &argv, true); +namespace grpc { +namespace testing { +static void QpsDriver() { RpcType rpc_type; GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type)); @@ -107,9 +111,20 @@ int main(int argc, char** argv) { client_config, FLAGS_num_clients, server_config, FLAGS_num_servers, FLAGS_warmup_seconds, FLAGS_benchmark_seconds, FLAGS_local_workers); - ReportQPSPerCore(*result, server_config); - ReportLatency(*result); - ReportTimes(*result); + GetReporter()->ReportQPS(*result); + GetReporter()->ReportQPSPerCore(*result, server_config); + GetReporter()->ReportLatency(*result); + GetReporter()->ReportTimes(*result); +} + +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + + signal(SIGPIPE, SIG_IGN); + grpc::testing::QpsDriver(); return 0; } diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc index 9a81d0fc90..63a37ae07e 100644 --- a/test/cpp/qps/qps_test.cc +++ b/test/cpp/qps/qps_test.cc @@ -31,12 +31,15 @@ * */ +#include <set> + #include <grpc/support/log.h> #include <signal.h> #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -64,14 +67,16 @@ static void RunQPS() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPSPerCore(*result, server_config); - ReportLatency(*result); + GetReporter()->ReportQPSPerCore(*result, server_config); + GetReporter()->ReportLatency(*result); } } // namespace testing } // namespace grpc int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + signal(SIGPIPE, SIG_IGN); grpc::testing::RunQPS(); diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 3115ff3bfb..e116175e3b 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -39,27 +39,55 @@ namespace grpc { namespace testing { -// QPS: XXX -void ReportQPS(const ScenarioResult& result) { +void CompositeReporter::add(std::unique_ptr<Reporter> reporter) { + reporters_.emplace_back(std::move(reporter)); +} + +void CompositeReporter::ReportQPS(const ScenarioResult& result) const { + for (size_t i = 0; i < reporters_.size(); ++i) { + reporters_[i]->ReportQPS(result); + } +} + +void CompositeReporter::ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& config) const { + for (size_t i = 0; i < reporters_.size(); ++i) { + reporters_[i]->ReportQPSPerCore(result, config); + } +} + +void CompositeReporter::ReportLatency(const ScenarioResult& result) const { + for (size_t i = 0; i < reporters_.size(); ++i) { + reporters_[i]->ReportLatency(result); + } +} + +void CompositeReporter::ReportTimes(const ScenarioResult& result) const { + for (size_t i = 0; i < reporters_.size(); ++i) { + reporters_[i]->ReportTimes(result); + } +} + + +void GprLogReporter::ReportQPS(const ScenarioResult& result) const { gpr_log(GPR_INFO, "QPS: %.1f", result.latencies.Count() / average(result.client_resources, [](ResourceUsage u) { return u.wall_time; })); } -// QPS: XXX (YYY/server core) -void ReportQPSPerCore(const ScenarioResult& result, - const ServerConfig& server_config) { - auto qps = result.latencies.Count() / - average(result.client_resources, - [](ResourceUsage u) { return u.wall_time; }); +void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& server_config) const { + auto qps = + result.latencies.Count() / + average(result.client_resources, + [](ResourceUsage u) { return u.wall_time; }); gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps, qps / server_config.threads()); } -// Latency (50/90/95/99/99.9%-ile): AA/BB/CC/DD/EE us -void ReportLatency(const ScenarioResult& result) { +void GprLogReporter::ReportLatency(const ScenarioResult& result) const { gpr_log(GPR_INFO, "Latencies (50/90/95/99/99.9%%-ile): %.1f/%.1f/%.1f/%.1f/%.1f us", result.latencies.Percentile(50) / 1000, @@ -69,7 +97,7 @@ void ReportLatency(const ScenarioResult& result) { result.latencies.Percentile(99.9) / 1000); } -void ReportTimes(const ScenarioResult& result) { +void GprLogReporter::ReportTimes(const ScenarioResult& result) const { gpr_log(GPR_INFO, "Server system time: %.2f%%", 100.0 * sum(result.server_resources, [](ResourceUsage u) { return u.system_time; }) / diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 343e426ca4..630275ecda 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -34,22 +34,77 @@ #ifndef TEST_QPS_REPORT_H #define TEST_QPS_REPORT_H +#include <memory> +#include <set> +#include <vector> +#include <grpc++/config.h> + #include "test/cpp/qps/driver.h" +#include "test/cpp/qps/qpstest.grpc.pb.h" namespace grpc { namespace testing { -// QPS: XXX -void ReportQPS(const ScenarioResult& result); -// QPS: XXX (YYY/server core) -void ReportQPSPerCore(const ScenarioResult& result, const ServerConfig& config); -// Latency (50/90/95/99/99.9%-ile): AA/BB/CC/DD/EE us -void ReportLatency(const ScenarioResult& result); -// Server system time: XX% -// Server user time: XX% -// Client system time: XX% -// Client user time: XX% -void ReportTimes(const ScenarioResult& result); +/** Interface for all reporters. */ +class Reporter { + public: + /** Construct a reporter with the given \a name. */ + Reporter(const string& name) : name_(name) {} + + virtual ~Reporter() {} + + /** Returns this reporter's name. + * + * Names are constants, set at construction time. */ + string name() const { return name_; } + + /** Reports QPS for the given \a result. */ + virtual void ReportQPS(const ScenarioResult& result) const = 0; + + /** Reports QPS per core as (YYY/server core). */ + virtual void ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& config) const = 0; + + /** Reports latencies for the 50, 90, 95, 99 and 99.9 percentiles, in ms. */ + virtual void ReportLatency(const ScenarioResult& result) const = 0; + + /** Reports system and user time for client and server systems. */ + virtual void ReportTimes(const ScenarioResult& result) const = 0; + + private: + const string name_; +}; + +/** A composite for all reporters to be considered. */ +class CompositeReporter : public Reporter { + public: + CompositeReporter() : Reporter("CompositeReporter") {} + + /** Adds a \a reporter to the composite. */ + void add(std::unique_ptr<Reporter> reporter); + + void ReportQPS(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& config) const GRPC_OVERRIDE; + void ReportLatency(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; + + private: + std::vector<std::unique_ptr<Reporter> > reporters_; +}; + +/** Reporter to gpr_log(GPR_INFO). */ +class GprLogReporter : public Reporter { + public: + GprLogReporter(const string& name) : Reporter(name) {} + + private: + void ReportQPS(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& config) const GRPC_OVERRIDE; + void ReportLatency(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; +}; } // namespace testing } // namespace grpc diff --git a/test/cpp/qps/sync_streaming_ping_pong_test.cc b/test/cpp/qps/sync_streaming_ping_pong_test.cc index 218306846b..d53905a779 100644 --- a/test/cpp/qps/sync_streaming_ping_pong_test.cc +++ b/test/cpp/qps/sync_streaming_ping_pong_test.cc @@ -31,12 +31,15 @@ * */ +#include <set> + #include <grpc/support/log.h> #include <signal.h> #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -63,14 +66,15 @@ static void RunSynchronousStreamingPingPong() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPS(*result); - ReportLatency(*result); + GetReporter()->ReportQPS(*result); + GetReporter()->ReportLatency(*result); } - } // namespace testing } // namespace grpc int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + signal(SIGPIPE, SIG_IGN); grpc::testing::RunSynchronousStreamingPingPong(); diff --git a/test/cpp/qps/sync_unary_ping_pong_test.cc b/test/cpp/qps/sync_unary_ping_pong_test.cc index 137ef79f2f..d276d13a43 100644 --- a/test/cpp/qps/sync_unary_ping_pong_test.cc +++ b/test/cpp/qps/sync_unary_ping_pong_test.cc @@ -31,12 +31,15 @@ * */ +#include <set> + #include <grpc/support/log.h> #include <signal.h> #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -63,14 +66,16 @@ static void RunSynchronousUnaryPingPong() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPS(*result); - ReportLatency(*result); + GetReporter()->ReportQPS(*result); + GetReporter()->ReportLatency(*result); } } // namespace testing } // namespace grpc int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + signal(SIGPIPE, SIG_IGN); grpc::testing::RunSynchronousUnaryPingPong(); |