mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 12:57:31 +02:00
Add wstest compression option
This commit is contained in:
@ -2,6 +2,7 @@ Version 83:
|
|||||||
|
|
||||||
* Add flat_static_buffer::mutable_data
|
* Add flat_static_buffer::mutable_data
|
||||||
* Add buffer_front
|
* Add buffer_front
|
||||||
|
* Add wstest compression option
|
||||||
|
|
||||||
WebSocket
|
WebSocket
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace asio = boost::asio;
|
namespace asio = boost::asio;
|
||||||
namespace ip = boost::asio::ip;
|
namespace ip = boost::asio::ip;
|
||||||
@ -94,6 +96,7 @@ public:
|
|||||||
asio::io_service& ios,
|
asio::io_service& ios,
|
||||||
tcp::endpoint const& ep,
|
tcp::endpoint const& ep,
|
||||||
std::size_t messages,
|
std::size_t messages,
|
||||||
|
bool deflate,
|
||||||
report& rep,
|
report& rep,
|
||||||
test_buffer const& tb)
|
test_buffer const& tb)
|
||||||
: log_(log)
|
: log_(log)
|
||||||
@ -105,9 +108,11 @@ public:
|
|||||||
, strand_(ios)
|
, strand_(ios)
|
||||||
{
|
{
|
||||||
ws::permessage_deflate pmd;
|
ws::permessage_deflate pmd;
|
||||||
pmd.client_enable = false;
|
pmd.client_enable = deflate;
|
||||||
ws_.set_option(pmd);
|
ws_.set_option(pmd);
|
||||||
ws_.binary(true);
|
ws_.binary(true);
|
||||||
|
ws_.auto_fragment(false);
|
||||||
|
ws_.write_buffer_size(64 * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
~connection()
|
~connection()
|
||||||
@ -275,11 +280,11 @@ main(int argc, char** argv)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Check command line arguments.
|
// Check command line arguments.
|
||||||
if(argc != 6)
|
if(argc != 8)
|
||||||
{
|
{
|
||||||
std::cerr <<
|
std::cerr <<
|
||||||
"Usage: " << argv[0] <<
|
"Usage: " << argv[0] <<
|
||||||
" <address> <port> <trials> <messages> <workers>";
|
" <address> <port> <trials> <messages> <workers> <threads> <compression:0|1>";
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,6 +293,8 @@ main(int argc, char** argv)
|
|||||||
auto const trials = static_cast<std::size_t>(std::atoi(argv[3]));
|
auto const trials = static_cast<std::size_t>(std::atoi(argv[3]));
|
||||||
auto const messages= static_cast<std::size_t>(std::atoi(argv[4]));
|
auto const messages= static_cast<std::size_t>(std::atoi(argv[4]));
|
||||||
auto const workers = static_cast<std::size_t>(std::atoi(argv[5]));
|
auto const workers = static_cast<std::size_t>(std::atoi(argv[5]));
|
||||||
|
auto const threads = static_cast<std::size_t>(std::atoi(argv[6]));
|
||||||
|
auto const deflate = static_cast<bool>(std::atoi(argv[7]));
|
||||||
auto const work = (messages + workers - 1) / workers;
|
auto const work = (messages + workers - 1) / workers;
|
||||||
test_buffer tb;
|
test_buffer tb;
|
||||||
for(auto i = trials; i; --i)
|
for(auto i = trials; i; --i)
|
||||||
@ -302,13 +309,22 @@ main(int argc, char** argv)
|
|||||||
ios,
|
ios,
|
||||||
tcp::endpoint{address, port},
|
tcp::endpoint{address, port},
|
||||||
work,
|
work,
|
||||||
|
deflate,
|
||||||
rep,
|
rep,
|
||||||
tb);
|
tb);
|
||||||
sp->run();
|
sp->run();
|
||||||
}
|
}
|
||||||
timer t;
|
timer clock;
|
||||||
|
std::vector<std::thread> tv;
|
||||||
|
if(threads > 1)
|
||||||
|
{
|
||||||
|
tv.reserve(threads);
|
||||||
|
tv.emplace_back([&ios]{ ios.run(); });
|
||||||
|
}
|
||||||
ios.run();
|
ios.run();
|
||||||
auto const elapsed = t.elapsed();
|
for(auto& t : tv)
|
||||||
|
t.join();
|
||||||
|
auto const elapsed = clock.elapsed();
|
||||||
dout <<
|
dout <<
|
||||||
throughput(elapsed, rep.bytes()) << " bytes/s in " <<
|
throughput(elapsed, rep.bytes()) << " bytes/s in " <<
|
||||||
(std::chrono::duration_cast<
|
(std::chrono::duration_cast<
|
||||||
|
Reference in New Issue
Block a user