use option i to accept input URI list file
This commit is contained in:
parent
db071ca35c
commit
41dd6d0205
|
@ -607,8 +607,7 @@ namespace {
|
||||||
void print_usage(std::ostream& out)
|
void print_usage(std::ostream& out)
|
||||||
{
|
{
|
||||||
out << R"(
|
out << R"(
|
||||||
Usage: h2load [OPTIONS]... <URI>...
|
Usage: h2load [OPTIONS]... [URI]...
|
||||||
h2load [OPTIONS]... <URI_LIST_FILE>
|
|
||||||
benchmarking tool for HTTP/2 and SPDY server)" << std::endl;
|
benchmarking tool for HTTP/2 and SPDY server)" << std::endl;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -626,13 +625,6 @@ void print_help(std::ostream& out)
|
||||||
host and port in the subsequent URIs, if present,
|
host and port in the subsequent URIs, if present,
|
||||||
are ignored. Those in the first URI are used
|
are ignored. Those in the first URI are used
|
||||||
solely.
|
solely.
|
||||||
<URI_LIST_FILE> Path of a file with multiple URIs are seperated
|
|
||||||
by EOLs. URIs are used in this order for each
|
|
||||||
client. All URIs are used, then first URI is
|
|
||||||
used and then 2nd URI, and so on. The scheme,
|
|
||||||
host and port in the subsequent URIs, if present,
|
|
||||||
are ignored. Those in the first URI are used
|
|
||||||
solely.
|
|
||||||
Options:
|
Options:
|
||||||
-n, --requests=<N> Number of requests. Default: )"
|
-n, --requests=<N> Number of requests. Default: )"
|
||||||
<< config.nreqs << R"(
|
<< config.nreqs << R"(
|
||||||
|
@ -640,6 +632,15 @@ Options:
|
||||||
<< config.nclients << R"(
|
<< config.nclients << R"(
|
||||||
-t, --threads=<N> Number of native threads. Default: )"
|
-t, --threads=<N> Number of native threads. Default: )"
|
||||||
<< config.nthreads << R"(
|
<< config.nthreads << R"(
|
||||||
|
-i, --input-file=<FILE>
|
||||||
|
Path of a file with multiple URIs are seperated
|
||||||
|
by EOLs. This option will disable URIs getting
|
||||||
|
from stdin. URIs are used in this order for each
|
||||||
|
client. All URIs are used, then first URI is
|
||||||
|
used and then 2nd URI, and so on. The scheme,
|
||||||
|
host and port in the subsequent URIs, if present,
|
||||||
|
are ignored. Those in the first URI are used
|
||||||
|
solely.
|
||||||
-m, --max-concurrent-streams=(auto|<N>)
|
-m, --max-concurrent-streams=(auto|<N>)
|
||||||
Max concurrent streams to issue per session. If
|
Max concurrent streams to issue per session. If
|
||||||
"auto" is given, the number of given URIs is
|
"auto" is given, the number of given URIs is
|
||||||
|
@ -686,6 +687,7 @@ int main(int argc, char **argv)
|
||||||
{"max-concurrent-streams", required_argument, nullptr, 'm'},
|
{"max-concurrent-streams", required_argument, nullptr, 'm'},
|
||||||
{"window-bits", required_argument, nullptr, 'w'},
|
{"window-bits", required_argument, nullptr, 'w'},
|
||||||
{"connection-window-bits", required_argument, nullptr, 'W'},
|
{"connection-window-bits", required_argument, nullptr, 'W'},
|
||||||
|
{"input-file", required_argument, nullptr, 'i'},
|
||||||
{"header", required_argument, nullptr, 'H'},
|
{"header", required_argument, nullptr, 'H'},
|
||||||
{"no-tls-proto", required_argument, nullptr, 'p'},
|
{"no-tls-proto", required_argument, nullptr, 'p'},
|
||||||
{"verbose", no_argument, nullptr, 'v'},
|
{"verbose", no_argument, nullptr, 'v'},
|
||||||
|
@ -694,7 +696,7 @@ int main(int argc, char **argv)
|
||||||
{nullptr, 0, nullptr, 0 }
|
{nullptr, 0, nullptr, 0 }
|
||||||
};
|
};
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
auto c = getopt_long(argc, argv, "hvW:c:m:n:p:t:w:H:", long_options,
|
auto c = getopt_long(argc, argv, "hvW:c:m:n:p:t:w:H:i:", long_options,
|
||||||
&option_index);
|
&option_index);
|
||||||
if(c == -1) {
|
if(c == -1) {
|
||||||
break;
|
break;
|
||||||
|
@ -765,6 +767,10 @@ int main(int argc, char **argv)
|
||||||
util::inp_strlower(config.custom_headers.back().first);
|
util::inp_strlower(config.custom_headers.back().first);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'i': {
|
||||||
|
config.ifile = std::string(optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'p':
|
case 'p':
|
||||||
if(util::strieq(NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, optarg)) {
|
if(util::strieq(NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, optarg)) {
|
||||||
config.no_tls_proto = Config::PROTO_HTTP2;
|
config.no_tls_proto = Config::PROTO_HTTP2;
|
||||||
|
@ -804,9 +810,11 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(argc == optind) {
|
if(argc == optind) {
|
||||||
std::cerr << "no URI given" << std::endl;
|
if(config.ifile.empty()){
|
||||||
|
std::cerr << "no URI or input file given" << std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(config.nreqs == 0) {
|
if(config.nreqs == 0) {
|
||||||
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."
|
||||||
|
@ -866,14 +874,23 @@ int main(int argc, char **argv)
|
||||||
// this URI and ignore those in the remaining URIs if present.
|
// this URI and ignore those in the remaining URIs if present.
|
||||||
http_parser_url u;
|
http_parser_url u;
|
||||||
memset(&u, 0, sizeof(u));
|
memset(&u, 0, sizeof(u));
|
||||||
auto uri = argv[optind];
|
auto uri = "";
|
||||||
|
|
||||||
std::ifstream uri_file;
|
std::ifstream uri_file;
|
||||||
std::string line_uri;
|
std::string line_uri;
|
||||||
if (std::ifstream(uri)) {
|
|
||||||
uri_file.open(uri, std::ifstream::in);
|
if (config.ifile.empty()) {
|
||||||
|
uri = argv[optind];
|
||||||
|
} else {
|
||||||
|
if (std::ifstream(config.ifile)) {
|
||||||
|
uri_file.open(config.ifile, std::ifstream::in);
|
||||||
|
// get first line as first uri
|
||||||
std::getline (uri_file, line_uri);
|
std::getline (uri_file, line_uri);
|
||||||
uri = (char *)line_uri.c_str();
|
uri = (char *)line_uri.c_str();
|
||||||
|
} else {
|
||||||
|
std::cerr << "cannot read input file: " << config.ifile << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(http_parser_parse_url(uri, strlen(uri), 0, &u) != 0 ||
|
if(http_parser_parse_url(uri, strlen(uri), 0, &u) != 0 ||
|
||||||
|
@ -894,6 +911,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
reqlines.push_back(get_reqline(uri, u));
|
reqlines.push_back(get_reqline(uri, u));
|
||||||
|
|
||||||
|
if (config.ifile.empty()) {
|
||||||
++optind;
|
++optind;
|
||||||
for(int i = optind; i < argc; ++i) {
|
for(int i = optind; i < argc; ++i) {
|
||||||
memset(&u, 0, sizeof(u));
|
memset(&u, 0, sizeof(u));
|
||||||
|
@ -907,7 +925,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
reqlines.push_back(get_reqline(uri, u));
|
reqlines.push_back(get_reqline(uri, u));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if(uri_file.is_open()) {
|
if(uri_file.is_open()) {
|
||||||
//load rest uris from URI_LIST_FILE
|
//load rest uris from URI_LIST_FILE
|
||||||
while(std::getline (uri_file, line_uri)) {
|
while(std::getline (uri_file, line_uri)) {
|
||||||
|
@ -922,6 +940,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
uri_file.close();
|
uri_file.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(config.max_concurrent_streams == -1) {
|
if(config.max_concurrent_streams == -1) {
|
||||||
config.max_concurrent_streams = reqlines.size();
|
config.max_concurrent_streams = reqlines.size();
|
||||||
|
|
|
@ -53,6 +53,7 @@ struct Config {
|
||||||
std::vector<std::pair<std::string, std::string>> custom_headers;
|
std::vector<std::pair<std::string, std::string>> custom_headers;
|
||||||
std::string scheme;
|
std::string scheme;
|
||||||
std::string host;
|
std::string host;
|
||||||
|
std::string ifile;
|
||||||
addrinfo *addrs;
|
addrinfo *addrs;
|
||||||
size_t nreqs;
|
size_t nreqs;
|
||||||
size_t nclients;
|
size_t nclients;
|
||||||
|
|
Loading…
Reference in New Issue