MCPcopy Create free account
hub / github.com/boostorg/beast / main

Function main

test/bench/wsload/wsload.cpp:272–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272int
273main(int argc, char** argv)
274{
275 beast::unit_test::dstream dout(std::cerr);
276
277 try
278 {
279 // Check command line arguments.
280 if(argc != 8)
281 {
282 std::cerr <<
283 "Usage: bench-wsload <address> <port> <trials> <messages> <workers> <threads> <compression:0|1>";
284 return EXIT_FAILURE;
285 }
286
287 auto const address = net::ip::make_address(argv[1]);
288 auto const port = static_cast<unsigned short>(std::atoi(argv[2]));
289 auto const trials = static_cast<std::size_t>(std::atoi(argv[3]));
290 auto const messages= static_cast<std::size_t>(std::atoi(argv[4]));
291 auto const workers = static_cast<std::size_t>(std::atoi(argv[5]));
292 auto const threads = static_cast<std::size_t>(std::atoi(argv[6]));
293 auto const deflate = std::atoi(argv[7]) != 0;
294 auto const work = (messages + workers - 1) / workers;
295 test_buffer tb;
296 for(auto i = trials; i != 0; --i)
297 {
298 report rep;
299 net::io_context ioc{1};
300 for(auto j = workers; j; --j)
301 {
302 auto sp =
303 std::make_shared<connection>(
304 ioc,
305 tcp::endpoint{address, port},
306 work,
307 deflate,
308 rep,
309 tb);
310 sp->run();
311 }
312 timer clock;
313 std::vector<std::thread> tv;
314 if(threads > 1)
315 {
316 tv.reserve(threads);
317 tv.emplace_back([&ioc]{ ioc.run(); });
318 }
319 ioc.run();
320 for(auto& t : tv)
321 t.join();
322 auto const elapsed = clock.elapsed();
323 dout <<
324 throughput(elapsed, rep.bytes()) << " bytes/s in " <<
325 (std::chrono::duration_cast<
326 std::chrono::milliseconds>(
327 elapsed).count() / 1000.) << "ms and " <<
328 rep.bytes() << " bytes" << std::endl;
329 }

Callers

nothing calls this directly

Calls 5

bytesMethod · 0.80
whatMethod · 0.80
throughputFunction · 0.70
runMethod · 0.45
elapsedMethod · 0.45

Tested by

no test coverage detected