diff --git a/src/h2load.cc b/src/h2load.cc index 0c4121fe..df5e2a4c 100644 --- a/src/h2load.cc +++ b/src/h2load.cc @@ -1408,7 +1408,41 @@ int main(int argc, char **argv) { if (config.max_concurrent_streams == -1) { config.max_concurrent_streams = reqlines.size(); } + + // if not in rate mode and -C is set, warn that we are ignoring it + if (!config.is_rate_mode() && config.nconns != 0) { + std::cerr << "-C: warning: This option can only be used with -r, and" + << " will be ignored otherwise." << std::endl; + } + ssize_t n_time = 0; + ssize_t c_time = 0; + // only care about n_time and c_time in rate mode + if (config.is_rate_mode() && config.max_concurrent_streams != 0) { + n_time = (int)config.nreqs / + ((int)config.rate * (int)config.max_concurrent_streams); + c_time = (int)config.nconns / (int)config.rate; + } + // check to see if the two ways of determining test time conflict + if (config.is_rate_mode() && (int)config.max_concurrent_streams != 0 && + (n_time != c_time) && config.nreqs != 1 && config.nconns != 0) { + if ((int)config.nreqs < config.nconns) { + std::cerr << "-C, -n: warning: two different test times are being set. " + << std::endl; + std::cerr << "The test will run for " + << c_time + << " seconds." << std::endl; + } + else { + std::cout << "-C, -n: warning: two different test times are being set. " + << std::endl; + std::cout << "The smaller of the two will be chosen and the test will " + << "run for " + << std::min(n_time, c_time) + << " seconds." << std::endl; + } + } + Headers shared_nva; shared_nva.emplace_back(":scheme", config.scheme); if (config.port != config.default_port) { diff --git a/src/h2load.h b/src/h2load.h index a68b8dc5..986bf78c 100644 --- a/src/h2load.h +++ b/src/h2load.h @@ -57,6 +57,7 @@ using namespace nghttp2; namespace h2load { class Session; +struct Worker; struct Config { std::vector> nva;