benchmark_config.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
21 #include "absl/flags/flag.h"
22 
23 #include <grpc/support/log.h>
24 #include <grpcpp/create_channel.h>
26 
28 
29 ABSL_FLAG(bool, enable_log_reporter, true,
30  "Enable reporting of benchmark results through GprLog");
31 
32 ABSL_FLAG(std::string, scenario_result_file, "",
33  "Write JSON benchmark report to the file specified.");
34 
35 ABSL_FLAG(std::string, hashed_id, "", "Hash of the user id");
36 
37 ABSL_FLAG(std::string, test_name, "", "Name of the test being executed");
38 
39 ABSL_FLAG(std::string, sys_info, "", "System information");
40 
41 ABSL_FLAG(std::string, server_address, "localhost:50052",
42  "Address of the performance database server");
43 
44 ABSL_FLAG(std::string, tag, "", "Optional tag for the test");
45 
46 ABSL_FLAG(std::string, rpc_reporter_server_address, "",
47  "Server address for rpc reporter to send results to");
48 
49 ABSL_FLAG(bool, enable_rpc_reporter, false, "Enable use of RPC reporter");
50 
51 ABSL_FLAG(
52  std::string, rpc_reporter_credential_type,
54  "Credential type for communication to the QPS benchmark report server");
55 
56 namespace grpc {
57 namespace testing {
58 
59 static std::shared_ptr<Reporter> InitBenchmarkReporters() {
60  auto* composite_reporter = new CompositeReporter;
61  if (absl::GetFlag(FLAGS_enable_log_reporter)) {
62  composite_reporter->add(
63  std::unique_ptr<Reporter>(new GprLogReporter("LogReporter")));
64  }
65  if (!absl::GetFlag(FLAGS_scenario_result_file).empty()) {
66  composite_reporter->add(std::unique_ptr<Reporter>(new JsonReporter(
67  "JsonReporter", absl::GetFlag(FLAGS_scenario_result_file))));
68  }
69  if (absl::GetFlag(FLAGS_enable_rpc_reporter)) {
70  ChannelArguments channel_args;
71  std::shared_ptr<ChannelCredentials> channel_creds =
73  absl::GetFlag(FLAGS_rpc_reporter_credential_type), &channel_args);
74  GPR_ASSERT(!absl::GetFlag(FLAGS_rpc_reporter_server_address).empty());
75  composite_reporter->add(std::unique_ptr<Reporter>(new RpcReporter(
76  "RpcReporter",
77  grpc::CreateChannel(absl::GetFlag(FLAGS_rpc_reporter_server_address),
78  channel_creds))));
79  }
80 
81  return std::shared_ptr<Reporter>(composite_reporter);
82 }
83 
84 std::shared_ptr<Reporter> GetReporter() {
85  static std::shared_ptr<Reporter> reporter(InitBenchmarkReporters());
86  return reporter;
87 }
88 
89 } // namespace testing
90 } // namespace grpc
test_credentials_provider.h
testing
Definition: aws_request_signer_test.cc:25
log.h
grpc::testing::CredentialsProvider::GetChannelCredentials
virtual std::shared_ptr< ChannelCredentials > GetChannelCredentials(const std::string &type, ChannelArguments *args)=0
grpc::testing::CompositeReporter
Definition: report.h:74
grpc
Definition: grpcpp/alarm.h:33
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
ABSL_FLAG
ABSL_FLAG(bool, enable_log_reporter, true, "Enable reporting of benchmark results through GprLog")
grpc::testing::GprLogReporter
Definition: report.h:94
benchmark_config.h
server_address
std::string server_address("0.0.0.0:10000")
grpc::testing::kInsecureCredentialsType
const char kInsecureCredentialsType[]
Definition: test_credentials_provider.h:31
grpc::testing::RpcReporter
Definition: report.h:129
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
grpc::testing::CompositeReporter::add
void add(std::unique_ptr< Reporter > reporter)
Definition: report.cc:35
absl::GetFlag
ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag< T > &flag)
Definition: abseil-cpp/absl/flags/flag.h:98
grpc::CreateChannel
std::shared_ptr< Channel > CreateChannel(const grpc::string &target, const std::shared_ptr< ChannelCredentials > &creds)
grpc::testing::JsonReporter
Definition: report.h:112
google_benchmark.example.empty
def empty(state)
Definition: example.py:31
grpc::ChannelArguments
Definition: grpcpp/support/channel_arguments.h:39
credentials.h
grpc::testing::GetCredentialsProvider
CredentialsProvider * GetCredentialsProvider()
Definition: test_credentials_provider.cc:169
grpc::testing::InitBenchmarkReporters
static std::shared_ptr< Reporter > InitBenchmarkReporters()
Definition: benchmark_config.cc:59
grpc::testing::GetReporter
std::shared_ptr< Reporter > GetReporter()
Definition: benchmark_config.cc:84
create_channel.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:46