| 88 | }; |
| 89 | |
| 90 | int main(int argc, char** argv) |
| 91 | { |
| 92 | auto parser = optparse::OptionParser().version("1.0.0.0"); |
| 93 | |
| 94 | parser.add_option("-a", "--address").dest("address").set_default("127.0.0.1").help("Server address. Default: %default"); |
| 95 | parser.add_option("-p", "--port").dest("port").action("store").type("int").set_default(8443).help("Server port. Default: %default"); |
| 96 | parser.add_option("-t", "--threads").dest("threads").action("store").type("int").set_default(CPU::PhysicalCores()).help("Count of working threads. Default: %default"); |
| 97 | parser.add_option("-c", "--clients").dest("clients").action("store").type("int").set_default(100).help("Count of working clients. Default: %default"); |
| 98 | parser.add_option("-m", "--messages").dest("messages").action("store").type("int").set_default(1).help("Count of messages to send at the same time. Default: %default"); |
| 99 | parser.add_option("-z", "--seconds").dest("seconds").action("store").type("int").set_default(10).help("Count of seconds to benchmarking. Default: %default"); |
| 100 | |
| 101 | optparse::Values options = parser.parse_args(argc, argv); |
| 102 | |
| 103 | // Print help |
| 104 | if (options.get("help")) |
| 105 | { |
| 106 | parser.print_help(); |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | // Client parameters |
| 111 | std::string address(options.get("address")); |
| 112 | int port = options.get("port"); |
| 113 | int threads_count = options.get("threads"); |
| 114 | int clients_count = options.get("clients"); |
| 115 | int messages_count = options.get("messages"); |
| 116 | int seconds_count = options.get("seconds"); |
| 117 | |
| 118 | std::cout << "Server address: " << address << std::endl; |
| 119 | std::cout << "Server port: " << port << std::endl; |
| 120 | std::cout << "Working threads: " << threads_count << std::endl; |
| 121 | std::cout << "Working clients: " << clients_count << std::endl; |
| 122 | std::cout << "Working messages: " << messages_count << std::endl; |
| 123 | std::cout << "Seconds to benchmarking: " << seconds_count << std::endl; |
| 124 | |
| 125 | std::cout << std::endl; |
| 126 | |
| 127 | // Create a new Asio service |
| 128 | auto service = std::make_shared<Service>(threads_count); |
| 129 | |
| 130 | // Start the Asio service |
| 131 | std::cout << "Asio service starting..."; |
| 132 | service->Start(); |
| 133 | std::cout << "Done!" << std::endl; |
| 134 | |
| 135 | // Create and prepare a new SSL client context |
| 136 | auto context = std::make_shared<SSLContext>(asio::ssl::context::tlsv13); |
| 137 | context->set_default_verify_paths(); |
| 138 | context->set_root_certs(); |
| 139 | context->set_verify_mode(asio::ssl::verify_peer | asio::ssl::verify_fail_if_no_peer_cert); |
| 140 | context->load_verify_file("../tools/certificates/ca.pem"); |
| 141 | |
| 142 | // Create HTTPS Trace clients |
| 143 | std::vector<std::shared_ptr<HTTPSTraceClient>> clients; |
| 144 | for (int i = 0; i < clients_count; ++i) |
| 145 | { |
| 146 | // Create echo client |
| 147 | auto client = std::make_shared<HTTPSTraceClient>(service, context, address, port, messages_count); |
nothing calls this directly
no test coverage detected