aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cpp/qps/async_streaming_ping_pong_test.cc17
-rw-r--r--test/cpp/qps/async_unary_ping_pong_test.cc16
-rw-r--r--test/cpp/qps/qps_driver.cc30
-rw-r--r--test/cpp/qps/qps_test.cc16
-rw-r--r--test/cpp/qps/report.cc20
-rw-r--r--test/cpp/qps/report.h24
-rw-r--r--test/cpp/qps/sync_streaming_ping_pong_test.cc18
-rw-r--r--test/cpp/qps/sync_unary_ping_pong_test.cc13
8 files changed, 68 insertions, 86 deletions
diff --git a/test/cpp/qps/async_streaming_ping_pong_test.cc b/test/cpp/qps/async_streaming_ping_pong_test.cc
index 3106f26d66..c7367d876d 100644
--- a/test/cpp/qps/async_streaming_ping_pong_test.cc
+++ b/test/cpp/qps/async_streaming_ping_pong_test.cc
@@ -39,6 +39,7 @@
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/report.h"
+#include "test/cpp/util/benchmark_config.h"
namespace grpc {
namespace testing {
@@ -46,12 +47,10 @@ namespace testing {
static const int WARMUP = 5;
static const int BENCHMARK = 10;
-static void RunAsyncStreamingPingPong() {
+static void RunAsyncStreamingPingPong(
+ const std::vector<std::unique_ptr<Reporter> >& reporters) {
gpr_log(GPR_INFO, "Running Async Streaming Ping Pong");
- ReportersRegistry reporters_registry;
- reporters_registry.Register(new GprLogReporter("LogReporter"));
-
ClientConfig client_config;
client_config.set_client_type(ASYNC_CLIENT);
client_config.set_enable_ssl(false);
@@ -72,15 +71,19 @@ static void RunAsyncStreamingPingPong() {
std::set<ReportType> types;
types.insert(grpc::testing::ReportType::REPORT_QPS);
types.insert(grpc::testing::ReportType::REPORT_LATENCY);
- reporters_registry.Report({client_config, server_config, result}, types);
+ for (const auto& reporter : reporters) {
+ reporter->Report({client_config, server_config, result}, types);
+ }
}
} // namespace testing
} // namespace grpc
int main(int argc, char** argv) {
- signal(SIGPIPE, SIG_IGN);
- grpc::testing::RunAsyncStreamingPingPong();
+ grpc::testing::InitBenchmark(&argc, &argv, true);
+ const auto& reporters = grpc::testing::InitBenchmarkReporters();
+ signal(SIGPIPE, SIG_IGN);
+ grpc::testing::RunAsyncStreamingPingPong(reporters);
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 a51badd9c1..50e824bf0e 100644
--- a/test/cpp/qps/async_unary_ping_pong_test.cc
+++ b/test/cpp/qps/async_unary_ping_pong_test.cc
@@ -39,6 +39,7 @@
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/report.h"
+#include "test/cpp/util/benchmark_config.h"
namespace grpc {
namespace testing {
@@ -46,12 +47,10 @@ namespace testing {
static const int WARMUP = 5;
static const int BENCHMARK = 10;
-static void RunAsyncUnaryPingPong() {
+static void RunAsyncUnaryPingPong(
+ const std::vector<std::unique_ptr<Reporter> >& reporters) {
gpr_log(GPR_INFO, "Running Async Unary Ping Pong");
- ReportersRegistry reporters_registry;
- reporters_registry.Register(new GprLogReporter("LogReporter"));
-
ClientConfig client_config;
client_config.set_client_type(ASYNC_CLIENT);
client_config.set_enable_ssl(false);
@@ -72,15 +71,18 @@ static void RunAsyncUnaryPingPong() {
std::set<ReportType> types;
types.insert(grpc::testing::ReportType::REPORT_QPS);
types.insert(grpc::testing::ReportType::REPORT_LATENCY);
- reporters_registry.Report({client_config, server_config, result}, types);
+ for (const auto& reporter : reporters) {
+ reporter->Report({client_config, server_config, result}, types);
+ }
}
-
} // namespace testing
} // namespace grpc
int main(int argc, char** argv) {
+ grpc::testing::InitBenchmark(&argc, &argv, true);
+ const auto& reporters = grpc::testing::InitBenchmarkReporters();
signal(SIGPIPE, SIG_IGN);
- grpc::testing::RunAsyncUnaryPingPong();
+ grpc::testing::RunAsyncUnaryPingPong(reporters);
return 0;
}
diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc
index 3aa215b448..b06b88d8a0 100644
--- a/test/cpp/qps/qps_driver.cc
+++ b/test/cpp/qps/qps_driver.cc
@@ -31,6 +31,7 @@
*
*/
+#include <memory>
#include <set>
#include <gflags/gflags.h>
@@ -38,7 +39,7 @@
#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");
@@ -69,17 +70,13 @@ using grpc::testing::ClientType;
using grpc::testing::ServerType;
using grpc::testing::RpcType;
using grpc::testing::ResourceUsage;
-using grpc::testing::ReportersRegistry;
-using grpc::testing::GprLogReporter;
-using grpc::testing::ReportData;
using grpc::testing::ReportType;
-int main(int argc, char** argv) {
- grpc::testing::InitTest(&argc, &argv, true);
-
- ReportersRegistry reporters_registry;
- reporters_registry.Register(new GprLogReporter("LogReporter"));
+namespace grpc {
+namespace testing {
+static void QpsDriver(
+ const std::vector<std::unique_ptr<Reporter> >& reporters) {
RpcType rpc_type;
GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type));
@@ -118,7 +115,20 @@ int main(int argc, char** argv) {
std::set<ReportType> types;
types.insert(grpc::testing::ReportType::REPORT_ALL);
- reporters_registry.Report({client_config, server_config, result}, types);
+ for (const auto& reporter : reporters) {
+ reporter->Report({client_config, server_config, result}, types);
+ }
+}
+
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc::testing::InitBenchmark(&argc, &argv, true);
+ const auto& reporters = grpc::testing::InitBenchmarkReporters();
+
+ signal(SIGPIPE, SIG_IGN);
+ grpc::testing::QpsDriver(reporters);
return 0;
}
diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc
index 2f72519397..869ec19179 100644
--- a/test/cpp/qps/qps_test.cc
+++ b/test/cpp/qps/qps_test.cc
@@ -39,6 +39,7 @@
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/report.h"
+#include "test/cpp/util/benchmark_config.h"
namespace grpc {
namespace testing {
@@ -46,12 +47,9 @@ namespace testing {
static const int WARMUP = 5;
static const int BENCHMARK = 10;
-static void RunQPS() {
+static void RunQPS(const std::vector<std::unique_ptr<Reporter> >& reporters) {
gpr_log(GPR_INFO, "Running QPS test");
- ReportersRegistry reporters_registry;
- reporters_registry.Register(new GprLogReporter("LogReporter"));
-
ClientConfig client_config;
client_config.set_client_type(ASYNC_CLIENT);
client_config.set_enable_ssl(false);
@@ -72,16 +70,20 @@ static void RunQPS() {
std::set<ReportType> types;
types.insert(grpc::testing::ReportType::REPORT_QPS_PER_CORE);
types.insert(grpc::testing::ReportType::REPORT_LATENCY);
- reporters_registry.Report({client_config, server_config, result}, types);
-
+ for (const auto& reporter : reporters) {
+ reporter->Report({client_config, server_config, result}, types);
+ }
}
} // namespace testing
} // namespace grpc
int main(int argc, char** argv) {
+ grpc::testing::InitBenchmark(&argc, &argv, true);
+ const auto& reporters = grpc::testing::InitBenchmarkReporters();
+
signal(SIGPIPE, SIG_IGN);
- grpc::testing::RunQPS();
+ grpc::testing::RunQPS(reporters);
return 0;
}
diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc
index 72b3a3643d..55726fbd00 100644
--- a/test/cpp/qps/report.cc
+++ b/test/cpp/qps/report.cc
@@ -39,26 +39,6 @@
namespace grpc {
namespace testing {
-// ReporterRegistry implementation.
-void ReportersRegistry::Register(const Reporter* reporter) {
- reporters_.emplace_back(reporter);
-}
-
-std::vector<string> ReportersRegistry::GetNamesRegistered() const {
- std::vector<string> names;
- for (const auto& reporter : reporters_) {
- names.push_back(reporter->name());
- }
- return names;
-}
-
-void ReportersRegistry::Report(const ReportData& data,
- const std::set<ReportType>& types) const {
- for (const auto& reporter : reporters_) {
- reporter->Report(data, types);
- }
-}
-
// Reporter implementation.
void Reporter::Report(const ReportData& data,
const std::set<ReportType>& types) const {
diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h
index e62b9deb32..64e92b1e89 100644
--- a/test/cpp/qps/report.h
+++ b/test/cpp/qps/report.h
@@ -71,30 +71,6 @@ enum ReportType {
class Reporter;
-/** A registry of Reporter instances.
- *
- * Instances registered will be taken into account by the Report() method.
- */
-class ReportersRegistry {
- public:
- /** Adds the \c reporter to the registry.
- * \attention Takes ownership of \c reporter. */
- void Register(const Reporter* reporter);
-
- /** Returns the names of the registered \c Reporter instances. */
- std::vector<string> GetNamesRegistered() const;
-
- /** Triggers the reporting for all registered \c Reporter instances.
- *
- * \param data Configuration and results for the scenario being reported.
- * \param types A collection of report types to include in the report. */
- void Report(const ReportData& data,
- const std::set<ReportType>& types) const;
-
- private:
- std::vector<std::unique_ptr<const Reporter> > reporters_;
-};
-
/** Interface for all reporters. */
class Reporter {
public:
diff --git a/test/cpp/qps/sync_streaming_ping_pong_test.cc b/test/cpp/qps/sync_streaming_ping_pong_test.cc
index ddc1573bfd..b17a3f6e48 100644
--- a/test/cpp/qps/sync_streaming_ping_pong_test.cc
+++ b/test/cpp/qps/sync_streaming_ping_pong_test.cc
@@ -39,6 +39,7 @@
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/report.h"
+#include "test/cpp/util/benchmark_config.h"
namespace grpc {
namespace testing {
@@ -46,12 +47,10 @@ namespace testing {
static const int WARMUP = 5;
static const int BENCHMARK = 10;
-static void RunSynchronousStreamingPingPong() {
+static void RunSynchronousStreamingPingPong(
+ const std::vector<std::unique_ptr<Reporter> >& reporters) {
gpr_log(GPR_INFO, "Running Synchronous Streaming Ping Pong");
- ReportersRegistry reporters_registry;
- reporters_registry.Register(new GprLogReporter("LogReporter"));
-
ClientConfig client_config;
client_config.set_client_type(SYNCHRONOUS_CLIENT);
client_config.set_enable_ssl(false);
@@ -71,16 +70,19 @@ static void RunSynchronousStreamingPingPong() {
std::set<ReportType> types;
types.insert(grpc::testing::ReportType::REPORT_QPS);
types.insert(grpc::testing::ReportType::REPORT_LATENCY);
- reporters_registry.Report({client_config, server_config, result}, types);
-
+ for (const auto& reporter : reporters) {
+ reporter->Report({client_config, server_config, result}, types);
+ }
}
-
} // namespace testing
} // namespace grpc
int main(int argc, char** argv) {
+ grpc::testing::InitBenchmark(&argc, &argv, true);
+ const auto& reporters = grpc::testing::InitBenchmarkReporters();
+
signal(SIGPIPE, SIG_IGN);
- grpc::testing::RunSynchronousStreamingPingPong();
+ grpc::testing::RunSynchronousStreamingPingPong(reporters);
return 0;
}
diff --git a/test/cpp/qps/sync_unary_ping_pong_test.cc b/test/cpp/qps/sync_unary_ping_pong_test.cc
index a1bd1f1705..ff4038a386 100644
--- a/test/cpp/qps/sync_unary_ping_pong_test.cc
+++ b/test/cpp/qps/sync_unary_ping_pong_test.cc
@@ -39,6 +39,7 @@
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/report.h"
+#include "test/cpp/util/benchmark_config.h"
namespace grpc {
namespace testing {
@@ -46,7 +47,8 @@ namespace testing {
static const int WARMUP = 5;
static const int BENCHMARK = 10;
-static void RunSynchronousUnaryPingPong() {
+static void RunSynchronousUnaryPingPong(
+ const std::vector<std::unique_ptr<Reporter> >& reporters) {
gpr_log(GPR_INFO, "Running Synchronous Unary Ping Pong");
ReportersRegistry reporters_registry;
@@ -71,15 +73,20 @@ static void RunSynchronousUnaryPingPong() {
std::set<ReportType> types;
types.insert(grpc::testing::ReportType::REPORT_QPS);
types.insert(grpc::testing::ReportType::REPORT_LATENCY);
- reporters_registry.Report({client_config, server_config, result}, types);
+ for (const auto& reporter : reporters) {
+ reporter->Report({client_config, server_config, result}, types);
+ }
}
} // namespace testing
} // namespace grpc
int main(int argc, char** argv) {
+ grpc::testing::InitBenchmark(&argc, &argv, true);
+ const auto& reporters = grpc::testing::InitBenchmarkReporters();
+
signal(SIGPIPE, SIG_IGN);
- grpc::testing::RunSynchronousUnaryPingPong();
+ grpc::testing::RunSynchronousUnaryPingPong(reporters);
return 0;
}