support uri list file input
This commit is contained in:
parent
dd02c4cd9b
commit
a6e1a40c05
|
@ -33,6 +33,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <future>
|
#include <future>
|
||||||
|
@ -605,7 +606,9 @@ void print_version(std::ostream& out)
|
||||||
namespace {
|
namespace {
|
||||||
void print_usage(std::ostream& out)
|
void print_usage(std::ostream& out)
|
||||||
{
|
{
|
||||||
out << R"(Usage: h2load [OPTIONS]... <URI>...
|
out << R"(
|
||||||
|
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
|
||||||
|
@ -623,6 +626,13 @@ 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"(
|
||||||
|
@ -857,9 +867,20 @@ int main(int argc, char **argv)
|
||||||
http_parser_url u;
|
http_parser_url u;
|
||||||
memset(&u, 0, sizeof(u));
|
memset(&u, 0, sizeof(u));
|
||||||
auto uri = argv[optind];
|
auto uri = argv[optind];
|
||||||
|
|
||||||
|
std::cout << uri << std::endl;
|
||||||
|
|
||||||
|
std::ifstream uri_file;
|
||||||
|
std::string line_uri;
|
||||||
|
if (std::ifstream(uri)) {
|
||||||
|
uri_file.open(uri, std::ifstream::in);
|
||||||
|
std::getline (uri_file, line_uri);
|
||||||
|
uri = (char *)line_uri.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
if(http_parser_parse_url(uri, strlen(uri), 0, &u) != 0 ||
|
if(http_parser_parse_url(uri, strlen(uri), 0, &u) != 0 ||
|
||||||
!util::has_uri_field(u, UF_SCHEMA) || !util::has_uri_field(u, UF_HOST)) {
|
!util::has_uri_field(u, UF_SCHEMA) || !util::has_uri_field(u, UF_HOST)) {
|
||||||
std::cerr << "invalid URI: " << uri << std::endl;
|
std::cerr << "invalid URI/URI_LIST_FILE: " << uri << std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -889,6 +910,21 @@ int main(int argc, char **argv)
|
||||||
reqlines.push_back(get_reqline(uri, u));
|
reqlines.push_back(get_reqline(uri, u));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uri_file.is_open()) {
|
||||||
|
//load rest uris from URI_LIST_FILE
|
||||||
|
while(std::getline (uri_file, line_uri)) {
|
||||||
|
auto uri = (char *)line_uri.c_str();
|
||||||
|
|
||||||
|
if(http_parser_parse_url(uri, strlen(uri), 0, &u) != 0) {
|
||||||
|
std::cerr << "invalid URI in URI_LIST_FILE: " << uri << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
reqlines.push_back(get_reqline(uri, u));
|
||||||
|
}
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue