Running clang-format

This commit is contained in:
Nora Shoemaker 2015-07-24 15:35:11 -07:00
parent 871a93e4aa
commit 12013508bf
2 changed files with 35 additions and 21 deletions

View File

@ -731,7 +731,8 @@ void Client::signal_write() { ev_io_start(worker->loop, &wev); }
Worker::Worker(uint32_t id, SSL_CTX *ssl_ctx, size_t req_todo, size_t nclients, Worker::Worker(uint32_t id, SSL_CTX *ssl_ctx, size_t req_todo, size_t nclients,
ssize_t rate, Config *config) ssize_t rate, Config *config)
: stats(req_todo), loop(ev_loop_new(0)), ssl_ctx(ssl_ctx), config(config), : stats(req_todo), loop(ev_loop_new(0)), ssl_ctx(ssl_ctx), config(config),
id(id), tls_info_report_done(false), current_second(0), nconns_made(0), nclients(nclients), rate(rate) { id(id), tls_info_report_done(false), current_second(0), nconns_made(0),
nclients(nclients), rate(rate) {
stats.req_todo = req_todo; stats.req_todo = req_todo;
progress_interval = std::max((size_t)1, req_todo / 10); progress_interval = std::max((size_t)1, req_todo / 10);
auto nreqs_per_client = req_todo / nclients; auto nreqs_per_client = req_todo / nclients;
@ -1028,13 +1029,16 @@ void print_help(std::ostream &out) {
Options: Options:
-n, --requests=<N> -n, --requests=<N>
Number of requests. Number of requests.
Default: )" << config.nreqs << R"( Default: )"
<< config.nreqs << R"(
-c, --clients=<N> -c, --clients=<N>
Number of concurrent clients. Number of concurrent clients.
Default: )" << config.nclients << R"( Default: )"
<< config.nclients << R"(
-t, --threads=<N> -t, --threads=<N>
Number of native threads. Number of native threads.
Default: )" << config.nthreads << R"( Default: )"
<< config.nthreads << R"(
-i, --input-file=<PATH> -i, --input-file=<PATH>
Path of a file with multiple URIs are separated by EOLs. Path of a file with multiple URIs are separated by EOLs.
This option will disable URIs getting from command-line. This option will disable URIs getting from command-line.
@ -1051,13 +1055,15 @@ Options:
-w, --window-bits=<N> -w, --window-bits=<N>
Sets the stream level initial window size to (2**<N>)-1. Sets the stream level initial window size to (2**<N>)-1.
For SPDY, 2**<N> is used instead. For SPDY, 2**<N> is used instead.
Default: )" << config.window_bits << R"( Default: )"
<< config.window_bits << R"(
-W, --connection-window-bits=<N> -W, --connection-window-bits=<N>
Sets the connection level initial window size to Sets the connection level initial window size to
(2**<N>)-1. For SPDY, if <N> is strictly less than 16, (2**<N>)-1. For SPDY, if <N> is strictly less than 16,
this option is ignored. Otherwise 2**<N> is used for this option is ignored. Otherwise 2**<N> is used for
SPDY. SPDY.
Default: )" << config.connection_window_bits << R"( Default: )"
<< config.connection_window_bits << R"(
-H, --header=<HEADER> -H, --header=<HEADER>
Add/Override a header to the requests. Add/Override a header to the requests.
--ciphers=<SUITE> --ciphers=<SUITE>
@ -1075,7 +1081,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=<PATH> -d, --data=<PATH>
Post FILE to server. The request method is changed to Post FILE to server. The request method is changed to
POST. POST.
@ -1100,7 +1107,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
@ -1333,7 +1341,8 @@ int main(int argc, char **argv) {
} }
if (config.is_rate_mode() && config.nconns < (ssize_t)config.nthreads) { if (config.is_rate_mode() && config.nconns < (ssize_t)config.nthreads) {
std::cerr << "-C, -t: the total number of connections must be greater than or equal " std::cerr << "-C, -t: the total number of connections must be greater than "
"or equal "
<< "to the number of threads." << std::endl; << "to the number of threads." << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -1459,11 +1468,12 @@ int main(int argc, char **argv) {
config.nreqs, config.nreqs,
(size_t)(config.max_concurrent_streams * config.nconns)) (size_t)(config.max_concurrent_streams * config.nconns))
<< " total requests." << std::endl; << " total requests." << std::endl;
actual_nreqs = std::min(config.nreqs, (size_t)(config.max_concurrent_streams * config.nreqs)); actual_nreqs = std::min(
config.nreqs, (size_t)(config.max_concurrent_streams * config.nreqs));
} }
} else { } else {
if (config.is_rate_mode() && config.max_concurrent_streams != 0 && if (config.is_rate_mode() && config.max_concurrent_streams != 0 &&
(n_time != c_time) && config.nreqs == 1 && config.nconns != 0) { (n_time != c_time) && config.nreqs == 1 && config.nconns != 0) {
actual_nreqs = config.max_concurrent_streams * config.nconns; actual_nreqs = config.max_concurrent_streams * config.nconns;
} }
} }
@ -1540,7 +1550,7 @@ int main(int argc, char **argv) {
if (config.is_rate_mode()) { if (config.is_rate_mode()) {
// set various config values // set various config values
if ((int)config.nreqs < config.nconns) { if ((int)config.nreqs < config.nconns) {
seconds = c_time; seconds = c_time;
} else if (config.nconns == 0) { } else if (config.nconns == 0) {
@ -1564,11 +1574,12 @@ int main(int argc, char **argv) {
auto nclients_extra_per_thread = 0; auto nclients_extra_per_thread = 0;
auto nclients_extra_rem_per_thread = 0; auto nclients_extra_rem_per_thread = 0;
// In rate mode, we want each Worker to create a total of // In rate mode, we want each Worker to create a total of
// C/t connections. // C/t connections.
if (config.is_rate_mode()) { if (config.is_rate_mode()) {
nclients_extra = config.nconns - (seconds * config.rate); nclients_extra = config.nconns - (seconds * config.rate);
nclients_extra_per_thread = nclients_extra / (ssize_t)config.nthreads; nclients_extra_per_thread = nclients_extra / (ssize_t)config.nthreads;
nclients_extra_rem_per_thread = (ssize_t)nclients_extra % (ssize_t)config.nthreads; nclients_extra_rem_per_thread =
(ssize_t)nclients_extra % (ssize_t)config.nthreads;
} }
std::cout << "starting benchmark..." << std::endl; std::cout << "starting benchmark..." << std::endl;
@ -1585,7 +1596,8 @@ int main(int argc, char **argv) {
auto rate = rate_per_thread + (rate_per_thread_rem-- > 0); auto rate = rate_per_thread + (rate_per_thread_rem-- > 0);
auto nclients = nclients_per_thread + (nclients_rem-- > 0); auto nclients = nclients_per_thread + (nclients_rem-- > 0);
if (config.is_rate_mode()) { if (config.is_rate_mode()) {
nclients = rate * seconds + nclients_extra_per_thread + (nclients_extra_rem_per_thread-- > 0); nclients = rate * seconds + nclients_extra_per_thread +
(nclients_extra_rem_per_thread-- > 0);
nreqs = nclients * config.max_concurrent_streams; nreqs = nclients * config.max_concurrent_streams;
} }
std::cout << "spawning thread #" << i << ": " << nclients std::cout << "spawning thread #" << i << ": " << nclients
@ -1603,14 +1615,16 @@ int main(int argc, char **argv) {
auto nclients_last = nclients_per_thread + (nclients_rem-- > 0); auto nclients_last = nclients_per_thread + (nclients_rem-- > 0);
auto rate_last = rate_per_thread + (rate_per_thread_rem-- > 0); auto rate_last = rate_per_thread + (rate_per_thread_rem-- > 0);
if (config.is_rate_mode()) { if (config.is_rate_mode()) {
nclients_last = rate_last * seconds + nclients_extra_per_thread + (nclients_extra_rem_per_thread-- > 0); nclients_last = rate_last * seconds + nclients_extra_per_thread +
(nclients_extra_rem_per_thread-- > 0);
nreqs_last = nclients_last * config.max_concurrent_streams; nreqs_last = nclients_last * config.max_concurrent_streams;
} }
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;
workers.push_back(make_unique<Worker>( workers.push_back(make_unique<Worker>(config.nthreads - 1, ssl_ctx,
config.nthreads - 1, ssl_ctx, nreqs_last, nclients_last, rate_last, &config)); nreqs_last, nclients_last, rate_last,
&config));
workers.back()->run(); workers.back()->run();
#ifndef NOTHREADS #ifndef NOTHREADS

View File

@ -183,8 +183,8 @@ struct Worker {
ev_timer timeout_watcher; ev_timer timeout_watcher;
ssize_t rate; ssize_t rate;
Worker(uint32_t id, SSL_CTX *ssl_ctx, size_t nreq_todo, size_t nclients, ssize_t rate, Worker(uint32_t id, SSL_CTX *ssl_ctx, size_t nreq_todo, size_t nclients,
Config *config); ssize_t rate, Config *config);
~Worker(); ~Worker();
Worker(Worker &&o) = default; Worker(Worker &&o) = default;
void run(); void run();