diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dc2a379..0bd75220 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 83: * Add flat_static_buffer::mutable_data * Add buffer_front +* Add wstest compression option WebSocket diff --git a/test/wstest/main.cpp b/test/wstest/main.cpp index 8ea22ef6..182a84db 100644 --- a/test/wstest/main.cpp +++ b/test/wstest/main.cpp @@ -21,6 +21,8 @@ #include #include #include +#include +#include namespace asio = boost::asio; namespace ip = boost::asio::ip; @@ -94,6 +96,7 @@ public: asio::io_service& ios, tcp::endpoint const& ep, std::size_t messages, + bool deflate, report& rep, test_buffer const& tb) : log_(log) @@ -105,9 +108,11 @@ public: , strand_(ios) { ws::permessage_deflate pmd; - pmd.client_enable = false; + pmd.client_enable = deflate; ws_.set_option(pmd); ws_.binary(true); + ws_.auto_fragment(false); + ws_.write_buffer_size(64 * 1024); } ~connection() @@ -275,11 +280,11 @@ main(int argc, char** argv) try { // Check command line arguments. - if(argc != 6) + if(argc != 8) { std::cerr << "Usage: " << argv[0] << - "
"; + "
"; return EXIT_FAILURE; } @@ -288,6 +293,8 @@ main(int argc, char** argv) auto const trials = static_cast(std::atoi(argv[3])); auto const messages= static_cast(std::atoi(argv[4])); auto const workers = static_cast(std::atoi(argv[5])); + auto const threads = static_cast(std::atoi(argv[6])); + auto const deflate = static_cast(std::atoi(argv[7])); auto const work = (messages + workers - 1) / workers; test_buffer tb; for(auto i = trials; i; --i) @@ -302,13 +309,22 @@ main(int argc, char** argv) ios, tcp::endpoint{address, port}, work, + deflate, rep, tb); sp->run(); } - timer t; + timer clock; + std::vector tv; + if(threads > 1) + { + tv.reserve(threads); + tv.emplace_back([&ios]{ ios.run(); }); + } ios.run(); - auto const elapsed = t.elapsed(); + for(auto& t : tv) + t.join(); + auto const elapsed = clock.elapsed(); dout << throughput(elapsed, rep.bytes()) << " bytes/s in " << (std::chrono::duration_cast<