clang-format
This commit is contained in:
parent
c9b1c91944
commit
afcd8d9ab1
|
@ -243,7 +243,7 @@ void rate_period_timeout_w_cb(struct ev_loop *loop, ev_timer *w, int revents) {
|
||||||
assert(worker->nclients == worker->clients.size());
|
assert(worker->nclients == worker->clients.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Called when the duration for infinite number of requests are over
|
// Called when the duration for infinite number of requests are over
|
||||||
|
@ -257,7 +257,7 @@ void duration_timeout_cb(struct ev_loop *loop, ev_timer *w, int revents) {
|
||||||
worker->stop_all_clients();
|
worker->stop_all_clients();
|
||||||
std::cout << "Stopped all clients for thread #" << worker->id << std::endl;
|
std::cout << "Stopped all clients for thread #" << worker->id << std::endl;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Called when the warmup duration for infinite number of requests are over
|
// Called when the warmup duration for infinite number of requests are over
|
||||||
|
@ -286,7 +286,7 @@ void warmup_timeout_cb(struct ev_loop *loop, ev_timer *w, int revents) {
|
||||||
}
|
}
|
||||||
|
|
||||||
worker->current_phase = Phase::MAIN_DURATION;
|
worker->current_phase = Phase::MAIN_DURATION;
|
||||||
|
|
||||||
ev_timer_start(worker->loop, &worker->duration_watcher);
|
ev_timer_start(worker->loop, &worker->duration_watcher);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -449,15 +449,15 @@ int Client::make_socket(addrinfo *addr) {
|
||||||
int Client::connect() {
|
int Client::connect() {
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (!worker->config->is_timing_based_mode()
|
if (!worker->config->is_timing_based_mode() ||
|
||||||
|| worker->current_phase == Phase::MAIN_DURATION) {
|
worker->current_phase == Phase::MAIN_DURATION) {
|
||||||
record_client_start_time();
|
record_client_start_time();
|
||||||
clear_connect_times();
|
clear_connect_times();
|
||||||
record_connect_start_time();
|
record_connect_start_time();
|
||||||
} else if (worker->current_phase == Phase::INITIAL_IDLE) {
|
} else if (worker->current_phase == Phase::INITIAL_IDLE) {
|
||||||
worker->current_phase = Phase::WARM_UP;
|
worker->current_phase = Phase::WARM_UP;
|
||||||
std::cout << "Warm-up started for thread #" << worker->id
|
std::cout << "Warm-up started for thread #" << worker->id << "."
|
||||||
<< "." << std::endl;
|
<< std::endl;
|
||||||
ev_timer_start(worker->loop, &worker->warmup_watcher);
|
ev_timer_start(worker->loop, &worker->warmup_watcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +646,8 @@ void Client::process_request_failure() {
|
||||||
if (req_inflight == 0) {
|
if (req_inflight == 0) {
|
||||||
terminate_session();
|
terminate_session();
|
||||||
}
|
}
|
||||||
std::cout << "Process Request Failure:" << worker->stats.req_failed << std::endl;
|
std::cout << "Process Request Failure:" << worker->stats.req_failed
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -749,7 +750,7 @@ void Client::on_header(int32_t stream_id, const uint8_t *name, size_t namelen,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status >= 200 && status < 300) {
|
if (status >= 200 && status < 300) {
|
||||||
++worker->stats.status[2];
|
++worker->stats.status[2];
|
||||||
stream.status_success = 1;
|
stream.status_success = 1;
|
||||||
|
@ -1227,7 +1228,7 @@ void Client::record_client_start_time() {
|
||||||
if (recorded(cstat.client_start_time)) {
|
if (recorded(cstat.client_start_time)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cstat.client_start_time = std::chrono::steady_clock::now();
|
cstat.client_start_time = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1347,7 +1348,7 @@ void Worker::run() {
|
||||||
client.release();
|
client.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (config->is_rate_mode()){
|
} else if (config->is_rate_mode()) {
|
||||||
ev_timer_again(loop, &timeout_watcher);
|
ev_timer_again(loop, &timeout_watcher);
|
||||||
|
|
||||||
// call callback so that we don't waste the first rate_period
|
// call callback so that we don't waste the first rate_period
|
||||||
|
@ -1384,8 +1385,8 @@ void Worker::sample_client_stat(ClientStat *cstat) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::report_progress() {
|
void Worker::report_progress() {
|
||||||
if (id != 0 || config->is_rate_mode() || stats.req_done % progress_interval
|
if (id != 0 || config->is_rate_mode() || stats.req_done % progress_interval ||
|
||||||
|| config->is_timing_based_mode()) {
|
config->is_timing_based_mode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1730,7 +1731,7 @@ std::unique_ptr<Worker> create_worker(uint32_t id, SSL_CTX *ssl_ctx,
|
||||||
if (config.is_timing_based_mode()) {
|
if (config.is_timing_based_mode()) {
|
||||||
std::cout << "spawning thread #" << id << ": " << nclients
|
std::cout << "spawning thread #" << id << ": " << nclients
|
||||||
<< " total client(s). Timing-based test with "
|
<< " total client(s). Timing-based test with "
|
||||||
<< config.warm_up_time << "s of warm-up time and "
|
<< config.warm_up_time << "s of warm-up time and "
|
||||||
<< config.duration << "s of main duration for measurements."
|
<< config.duration << "s of main duration for measurements."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1741,12 +1742,12 @@ std::unique_ptr<Worker> create_worker(uint32_t id, SSL_CTX *ssl_ctx,
|
||||||
|
|
||||||
if (config.is_rate_mode()) {
|
if (config.is_rate_mode()) {
|
||||||
return make_unique<Worker>(id, ssl_ctx, nreqs, nclients, rate, max_samples,
|
return make_unique<Worker>(id, ssl_ctx, nreqs, nclients, rate, max_samples,
|
||||||
&config);
|
&config);
|
||||||
} else {
|
} else {
|
||||||
// Here rate is same as client because the rate_timeout callback
|
// Here rate is same as client because the rate_timeout callback
|
||||||
// will be called only once
|
// will be called only once
|
||||||
return make_unique<Worker>(id, ssl_ctx, nreqs, nclients, nclients, max_samples,
|
return make_unique<Worker>(id, ssl_ctx, nreqs, nclients, nclients,
|
||||||
&config);
|
max_samples, &config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -2029,9 +2030,9 @@ int main(int argc, char **argv) {
|
||||||
{"warm-up-time", required_argument, &flag, 9},
|
{"warm-up-time", required_argument, &flag, 9},
|
||||||
{nullptr, 0, nullptr, 0}};
|
{nullptr, 0, nullptr, 0}};
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
auto c =
|
auto c = getopt_long(argc, argv,
|
||||||
getopt_long(argc, argv, "hvW:c:d:m:n:p:t:w:H:i:r:T:N:D:B:", long_options,
|
"hvW:c:d:m:n:p:t:w:H:i:r:T:N:D:B:", long_options,
|
||||||
&option_index);
|
&option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2345,8 +2346,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (config.nreqs == 0 && !config.is_timing_based_mode()) {
|
if (config.nreqs == 0 && !config.is_timing_based_mode()) {
|
||||||
std::cerr << "-n: the number of requests must be strictly greater than 0,"
|
std::cerr << "-n: the number of requests must be strictly greater than 0,"
|
||||||
<< "timing-based test is not being run."
|
<< "timing-based test is not being run." << std::endl;
|
||||||
<< std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2369,7 +2369,8 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
// With timing script, we don't distribute config.nreqs to each
|
// With timing script, we don't distribute config.nreqs to each
|
||||||
// client or thread.
|
// client or thread.
|
||||||
if (!config.timing_script && config.nreqs < config.nclients && !config.is_timing_based_mode()) {
|
if (!config.timing_script && config.nreqs < config.nclients &&
|
||||||
|
!config.is_timing_based_mode()) {
|
||||||
std::cerr << "-n, -c: the number of requests must be greater than or "
|
std::cerr << "-n, -c: the number of requests must be greater than or "
|
||||||
<< "equal to the clients." << std::endl;
|
<< "equal to the clients." << std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -2377,16 +2378,14 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (config.nclients < config.nthreads) {
|
if (config.nclients < config.nthreads) {
|
||||||
std::cerr << "-c, -t: the number of clients must be greater than or equal "
|
std::cerr << "-c, -t: the number of clients must be greater than or equal "
|
||||||
<< "to the number of threads."
|
<< "to the number of threads." << std::endl;
|
||||||
<< std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.is_timing_based_mode()) {
|
if (config.is_timing_based_mode()) {
|
||||||
if (config.nreqs != 0) {
|
if (config.nreqs != 0) {
|
||||||
std::cerr << "-n: the number of requests needs to be zero (0) for timing-"
|
std::cerr << "-n: the number of requests needs to be zero (0) for timing-"
|
||||||
<< "based test. Default value is 1."
|
<< "based test. Default value is 1." << std::endl;
|
||||||
<< std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2741,7 +2740,8 @@ int main(int argc, char **argv) {
|
||||||
bps = stats.bytes_total / config.duration;
|
bps = stats.bytes_total / config.duration;
|
||||||
} else {
|
} else {
|
||||||
auto secd = std::chrono::duration_cast<
|
auto secd = std::chrono::duration_cast<
|
||||||
std::chrono::duration<double, std::chrono::seconds::period>>(duration);
|
std::chrono::duration<double, std::chrono::seconds::period>>(
|
||||||
|
duration);
|
||||||
rps = stats.req_success / secd.count();
|
rps = stats.req_success / secd.count();
|
||||||
bps = stats.bytes_total / secd.count();
|
bps = stats.bytes_total / secd.count();
|
||||||
}
|
}
|
||||||
|
|
18
src/h2load.h
18
src/h2load.h
|
@ -221,12 +221,12 @@ struct Stats {
|
||||||
enum ClientState { CLIENT_IDLE, CLIENT_CONNECTED };
|
enum ClientState { CLIENT_IDLE, CLIENT_CONNECTED };
|
||||||
|
|
||||||
// This type tells whether the client is in warmup phase or not or is over
|
// This type tells whether the client is in warmup phase or not or is over
|
||||||
enum class Phase {
|
enum class Phase {
|
||||||
INITIAL_IDLE, // Initial idle state before warm-up phase
|
INITIAL_IDLE, // Initial idle state before warm-up phase
|
||||||
WARM_UP, // Warm up phase when no measurements are done
|
WARM_UP, // Warm up phase when no measurements are done
|
||||||
MAIN_DURATION, // Main measurement phase; if timing-based
|
MAIN_DURATION, // Main measurement phase; if timing-based
|
||||||
// test is not run, this is the default phase
|
// test is not run, this is the default phase
|
||||||
DURATION_OVER // This phase occurs after the measurements are over
|
DURATION_OVER // This phase occurs after the measurements are over
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Client;
|
struct Client;
|
||||||
|
@ -264,11 +264,13 @@ struct Worker {
|
||||||
ev_timer timeout_watcher;
|
ev_timer timeout_watcher;
|
||||||
// The next client ID this worker assigns
|
// The next client ID this worker assigns
|
||||||
uint32_t next_client_id;
|
uint32_t next_client_id;
|
||||||
// Keeps track of the current phase (for timing-based experiment) for the worker
|
// Keeps track of the current phase (for timing-based experiment) for the
|
||||||
|
// worker
|
||||||
Phase current_phase;
|
Phase current_phase;
|
||||||
// We need to keep track of the clients in order to stop them when needed
|
// We need to keep track of the clients in order to stop them when needed
|
||||||
std::vector<Client*> clients;
|
std::vector<Client *> clients;
|
||||||
// This is only active when there is not a bounded number of requests specified
|
// This is only active when there is not a bounded number of requests
|
||||||
|
// specified
|
||||||
ev_timer duration_watcher;
|
ev_timer duration_watcher;
|
||||||
ev_timer warmup_watcher;
|
ev_timer warmup_watcher;
|
||||||
|
|
||||||
|
@ -284,7 +286,7 @@ struct Worker {
|
||||||
// This function calls the destructors of all the clients.
|
// This function calls the destructors of all the clients.
|
||||||
void stop_all_clients();
|
void stop_all_clients();
|
||||||
// This function frees a client from the list of clients for this Worker.
|
// This function frees a client from the list of clients for this Worker.
|
||||||
void free_client(Client*);
|
void free_client(Client *);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Stream {
|
struct Stream {
|
||||||
|
|
Loading…
Reference in New Issue