wsperf blocking mode

This commit is contained in:
Peter Thorson
2012-03-11 17:02:14 -05:00
parent cfc491ffce
commit 6380f56384
2 changed files with 25 additions and 28 deletions

View File

@@ -138,7 +138,8 @@ public:
: m_coordinator(c),
m_ident(ident),
m_ua(ua),
m_num_workers(num_workers) {}
m_num_workers(num_workers),
m_blocking(num_workers == 0) {}
void on_open(connection_ptr con) {
std::stringstream o;
@@ -158,7 +159,12 @@ public:
r.type = PERF_TEST;
r.writer = writer_ptr(new ws_writer<endpoint_type>(con));
r.req = msg->get_payload();
m_coordinator.add_request(r);
if (m_blocking) {
r.process(0);
} else {
m_coordinator.add_request(r);
}
}
void on_fail(connection_ptr con) {
@@ -173,6 +179,7 @@ private:
std::string m_ident;
std::string m_ua;
unsigned int m_num_workers;
bool m_blocking;
};
// process_requests is the body function for a processing thread. It loops

View File

@@ -65,19 +65,14 @@ int start_server(po::variables_map& vm) {
wsperf::request_coordinator rc;
server::handler::ptr h;
if (num_threads == 0) {
std::cerr << "bad thread number" << std::endl;
return 1;
} else {
h = server::handler::ptr(
new wsperf::concurrent_handler<server>(
rc,
ident,
user_agent,
num_threads
)
);
}
h = server::handler::ptr(
new wsperf::concurrent_handler<server>(
rc,
ident,
user_agent,
num_threads
)
);
if (!silent) {
std::cout << "Starting wsperf server on port " << port << " with " << num_threads << " processing threads." << std::endl;
@@ -128,19 +123,14 @@ int start_client(po::variables_map& vm) {
wsperf::request_coordinator rc;
client::handler::ptr h;
if (num_threads == 0) {
std::cerr << "bad thread number" << std::endl;
return 1;
} else {
h = client::handler::ptr(
new wsperf::concurrent_handler<client>(
rc,
ident,
user_agent,
num_threads
)
);;
}
h = client::handler::ptr(
new wsperf::concurrent_handler<client>(
rc,
ident,
user_agent,
num_threads
)
);
if (!silent) {
std::cout << "Starting wsperf client connecting to " << uri << " with " << num_threads << " processing threads." << std::endl;