[EDGE-879] run clang-format and make sure style is good
This commit is contained in:
parent
2482dd7f77
commit
6b53f7ee19
|
@ -75,8 +75,7 @@ Config::Config()
|
||||||
: data_length(-1), addrs(nullptr), nreqs(1), nclients(1), nthreads(1),
|
: data_length(-1), addrs(nullptr), nreqs(1), nclients(1), nthreads(1),
|
||||||
max_concurrent_streams(-1), window_bits(30), connection_window_bits(30),
|
max_concurrent_streams(-1), window_bits(30), connection_window_bits(30),
|
||||||
no_tls_proto(PROTO_HTTP2), data_fd(-1), port(0), default_port(0),
|
no_tls_proto(PROTO_HTTP2), data_fd(-1), port(0), default_port(0),
|
||||||
verbose(false),
|
verbose(false), nconns(0), rate(0), current_worker(0) {}
|
||||||
nconns(0), rate(0), current_worker(0) {}
|
|
||||||
|
|
||||||
Config::~Config() {
|
Config::~Config() {
|
||||||
freeaddrinfo(addrs);
|
freeaddrinfo(addrs);
|
||||||
|
@ -86,9 +85,7 @@ Config::~Config() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Config::is_rate_mode() {
|
bool Config::is_rate_mode() { return (this->rate != 0); }
|
||||||
return (this->rate != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
|
@ -975,18 +972,16 @@ void second_timeout_cb(EV_P_ ev_timer *w, int revents) {
|
||||||
auto nclients_per_worker = config->rate;
|
auto nclients_per_worker = config->rate;
|
||||||
auto nreqs_per_worker = config->max_concurrent_streams * config->rate;
|
auto nreqs_per_worker = config->max_concurrent_streams * config->rate;
|
||||||
|
|
||||||
if(config->current_worker >= std::max(0. , (config->seconds - 1.))) {
|
if (config->current_worker >= std::max(0., (config->seconds - 1.))) {
|
||||||
nclients_per_worker = config->rate + config->conns_remainder;
|
nclients_per_worker = config->rate + config->conns_remainder;
|
||||||
nreqs_per_worker = (int)config->max_concurrent_streams *
|
nreqs_per_worker = (int)config->max_concurrent_streams *
|
||||||
(config->rate + config->conns_remainder);
|
(config->rate + config->conns_remainder);
|
||||||
ev_timer_stop(config->rate_loop, w);
|
ev_timer_stop(config->rate_loop, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
config->workers.push_back(make_unique<Worker>(config->current_worker,
|
config->workers.push_back(
|
||||||
config->ssl_ctx,
|
make_unique<Worker>(config->current_worker, config->ssl_ctx,
|
||||||
nreqs_per_worker,
|
nreqs_per_worker, nclients_per_worker, config));
|
||||||
nclients_per_worker,
|
|
||||||
config));
|
|
||||||
|
|
||||||
config->current_worker++;
|
config->current_worker++;
|
||||||
|
|
||||||
|
@ -1068,7 +1063,8 @@ Options:
|
||||||
Available protocol: )";
|
Available protocol: )";
|
||||||
#endif // !HAVE_SPDYLAY
|
#endif // !HAVE_SPDYLAY
|
||||||
out << NGHTTP2_CLEARTEXT_PROTO_VERSION_ID << R"(
|
out << NGHTTP2_CLEARTEXT_PROTO_VERSION_ID << R"(
|
||||||
Default: )" << NGHTTP2_CLEARTEXT_PROTO_VERSION_ID << R"(
|
Default: )"
|
||||||
|
<< NGHTTP2_CLEARTEXT_PROTO_VERSION_ID << R"(
|
||||||
-d, --data=<FILE>
|
-d, --data=<FILE>
|
||||||
Post FILE to server. The request method is changed to
|
Post FILE to server. The request method is changed to
|
||||||
POST.
|
POST.
|
||||||
|
@ -1093,7 +1089,8 @@ Options:
|
||||||
-v, --verbose
|
-v, --verbose
|
||||||
Output debug information.
|
Output debug information.
|
||||||
--version Display version information and exit.
|
--version Display version information and exit.
|
||||||
-h, --help Display this help and exit.)" << std::endl;
|
-h, --help Display this help and exit.)"
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -1128,8 +1125,8 @@ int main(int argc, char **argv) {
|
||||||
{"num-conns", required_argument, nullptr, 'C'},
|
{"num-conns", required_argument, nullptr, 'C'},
|
||||||
{nullptr, 0, nullptr, 0}};
|
{nullptr, 0, nullptr, 0}};
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
auto c = getopt_long(argc, argv, "hvW:c:d:m:n:p:t:w:H:i:r:C:",
|
auto c = getopt_long(argc, argv, "hvW:c:d:m:n:p:t:w:H:i:r:C:", long_options,
|
||||||
long_options, &option_index);
|
&option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1227,8 +1224,7 @@ int main(int argc, char **argv) {
|
||||||
config.rate = strtoul(optarg, nullptr, 10);
|
config.rate = strtoul(optarg, nullptr, 10);
|
||||||
if (config.rate <= 0) {
|
if (config.rate <= 0) {
|
||||||
std::cerr << "-r: the rate at which connections are made "
|
std::cerr << "-r: the rate at which connections are made "
|
||||||
<< "must be positive."
|
<< "must be positive." << std::endl;
|
||||||
<< std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1236,8 +1232,7 @@ int main(int argc, char **argv) {
|
||||||
config.nconns = strtoul(optarg, nullptr, 10);
|
config.nconns = strtoul(optarg, nullptr, 10);
|
||||||
if (config.nconns <= 0) {
|
if (config.nconns <= 0) {
|
||||||
std::cerr << "-C: the total number of connections made "
|
std::cerr << "-C: the total number of connections made "
|
||||||
<< "must be positive."
|
<< "must be positive." << std::endl;
|
||||||
<< std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1311,15 +1306,13 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (config.nconns < 0) {
|
if (config.nconns < 0) {
|
||||||
std::cerr << "-C: the total number of connections made "
|
std::cerr << "-C: the total number of connections made "
|
||||||
<< "cannot be negative."
|
<< "cannot be negative." << std::endl;
|
||||||
<< std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.rate < 0) {
|
if (config.rate < 0) {
|
||||||
std::cerr << "-r: the rate at which connections are made "
|
std::cerr << "-r: the rate at which connections are made "
|
||||||
<< "cannot be negative."
|
<< "cannot be negative." << std::endl;
|
||||||
<< std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1519,8 +1512,8 @@ int main(int argc, char **argv) {
|
||||||
std::cout << "spawning thread #" << (config.nthreads - 1) << ": "
|
std::cout << "spawning thread #" << (config.nthreads - 1) << ": "
|
||||||
<< nclients_last << " concurrent clients, " << nreqs_last
|
<< nclients_last << " concurrent clients, " << nreqs_last
|
||||||
<< " total requests" << std::endl;
|
<< " total requests" << std::endl;
|
||||||
config.workers.push_back(make_unique<Worker>(config.nthreads - 1, ssl_ctx,
|
config.workers.push_back(make_unique<Worker>(
|
||||||
nreqs_last, nclients_last, &config));
|
config.nthreads - 1, ssl_ctx, nreqs_last, nclients_last, &config));
|
||||||
config.workers.back()->run();
|
config.workers.back()->run();
|
||||||
|
|
||||||
#ifndef NOTHREADS
|
#ifndef NOTHREADS
|
||||||
|
@ -1528,7 +1521,7 @@ int main(int argc, char **argv) {
|
||||||
fut.get();
|
fut.get();
|
||||||
}
|
}
|
||||||
#endif // NOTHREADS
|
#endif // NOTHREADS
|
||||||
} //!config.is_rate_mode()
|
} //! config.is_rate_mode()
|
||||||
// if in rate mode, create a new worker each second
|
// if in rate mode, create a new worker each second
|
||||||
else {
|
else {
|
||||||
// set various config values
|
// set various config values
|
||||||
|
@ -1537,11 +1530,9 @@ int main(int argc, char **argv) {
|
||||||
if ((int)config.nreqs < config.nconns) {
|
if ((int)config.nreqs < config.nconns) {
|
||||||
config.seconds = c_time;
|
config.seconds = c_time;
|
||||||
config.workers.reserve(config.seconds);
|
config.workers.reserve(config.seconds);
|
||||||
}
|
} else if (config.nconns == 0) {
|
||||||
else if (config.nconns == 0) {
|
|
||||||
config.seconds = n_time;
|
config.seconds = n_time;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
config.workers.reserve(config.seconds);
|
config.workers.reserve(config.seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue