MCPcopy Create free account
hub / github.com/apache/brpc / set_press_options

Function set_press_options

tools/rpc_press/rpc_press.cpp:48–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46DEFINE_bool(pretty, true, "output pretty jsons");
47
48bool set_press_options(pbrpcframework::PressOptions* options){
49 size_t dot_pos = FLAGS_method.find_last_of('.');
50 if (dot_pos == std::string::npos) {
51 LOG(ERROR) << "-method must be in form of: package.service.method";
52 return false;
53 }
54 options->service = FLAGS_method.substr(0, dot_pos);
55 options->method = FLAGS_method.substr(dot_pos + 1);
56 options->lb_policy = FLAGS_lb_policy;
57 options->test_req_rate = FLAGS_qps;
58 if (FLAGS_thread_num > 0) {
59 options->test_thread_num = FLAGS_thread_num;
60 } else {
61 if (FLAGS_qps <= 0) { // unlimited qps
62 options->test_thread_num = 50;
63 } else {
64 options->test_thread_num = FLAGS_qps / 10000;
65 if (options->test_thread_num < 1) {
66 options->test_thread_num = 1;
67 }
68 if (options->test_thread_num > 50) {
69 options->test_thread_num = 50;
70 }
71 }
72 }
73
74 const int rate_limit_per_thread = 1000000;
75 double req_rate_per_thread = options->test_req_rate / options->test_thread_num;
76 if (req_rate_per_thread > rate_limit_per_thread) {
77 LOG(ERROR) << "req_rate: " << (int64_t) req_rate_per_thread << " is too large in one thread. The rate limit is "
78 << rate_limit_per_thread << " in one thread";
79 return false;
80 }
81
82 options->input = FLAGS_input;
83 options->output = FLAGS_output;
84 options->connection_type = FLAGS_connection_type;
85 options->connect_timeout_ms = FLAGS_connection_timeout_ms;
86 options->timeout_ms = FLAGS_timeout_ms;
87 options->max_retry = FLAGS_max_retry;
88 options->protocol = FLAGS_protocol;
89 options->request_compress_type = FLAGS_request_compress_type;
90 options->response_compress_type = FLAGS_response_compress_type;
91 options->attachment_size = FLAGS_attachment_size;
92 options->host = FLAGS_server;
93 options->proto_file = FLAGS_proto;
94 options->proto_includes = FLAGS_inc;
95 return true;
96}
97
98int main(int argc, char* argv[]) {
99 // Parse gflags. We recommend you to use gflags as well

Callers 1

mainFunction · 0.85

Calls 2

find_last_ofMethod · 0.80
substrMethod · 0.80

Tested by

no test coverage detected