From 7c1f9d702eeddc43bafb5ddd268717ab4ab2f08a Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Sat, 10 Mar 2012 18:39:57 -0600 Subject: [PATCH] wsperf bug fixes --- examples/wsperf/case.cpp | 24 ++++++++++++++---------- examples/wsperf/case.hpp | 5 +++-- examples/wsperf/generic.cpp | 17 +++++++++-------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/examples/wsperf/case.cpp b/examples/wsperf/case.cpp index 6c2a401da7..f255297d09 100644 --- a/examples/wsperf/case.cpp +++ b/examples/wsperf/case.cpp @@ -57,14 +57,14 @@ using wsperf::case_handler; * Whether or not to return the full list of round trip times for each message * primarily useful for debugging. */ -case_handler::case_handler(wscmd::cmd& cmd) { - m_uri = extract_string(cmd,"uri"); - m_token = extract_string(cmd,"token"); - m_quantile_count = extract_number(cmd,"quantile_count"); - m_rtts = extract_bool(cmd,"rtts"); - m_bytes = 0; - m_pass = RUNNING; -} +case_handler::case_handler(wscmd::cmd& cmd) + : m_uri(extract_string(cmd,"uri")), + m_token(extract_string(cmd,"token")), + m_quantile_count(extract_number(cmd,"quantile_count")), + m_rtts(extract_bool(cmd,"rtts")), + m_pass(RUNNING), + m_timeout(0), + m_bytes(0) {} /// Starts a test by starting the timeout timer and marking the start time void case_handler::start(connection_ptr con, uint64_t timeout) { @@ -74,7 +74,9 @@ void case_handler::start(connection_ptr con, uint64_t timeout) { boost::posix_time::seconds(0)) ); - m_timer->expires_from_now(boost::posix_time::milliseconds(timeout)); + m_timeout = timeout; + + m_timer->expires_from_now(boost::posix_time::milliseconds(m_timeout)); m_timer->async_wait( boost::bind( &type::on_timer, @@ -109,7 +111,9 @@ void case_handler::end(connection_ptr con) { double total = 0; double seconds = 0; - m_timer->cancel(); + if (m_timeout > 0) { + m_timer->cancel(); + } // TODO: handle weird sizes and error conditions better if (m_end.size() > m_quantile_count) { diff --git a/examples/wsperf/case.hpp b/examples/wsperf/case.hpp index 97947d55fd..36764e79e6 100644 --- a/examples/wsperf/case.hpp +++ b/examples/wsperf/case.hpp @@ -119,7 +119,6 @@ protected: RUNNING = 3 }; - std::string m_name; std::string m_uri; std::string m_token; size_t m_quantile_count; @@ -127,7 +126,9 @@ protected: std::string m_data; status m_pass; - boost::shared_ptr m_timer; + + uint64_t m_timeout; + boost::shared_ptr m_timer; boost::chrono::steady_clock::time_point m_start; std::vector m_end; diff --git a/examples/wsperf/generic.cpp b/examples/wsperf/generic.cpp index 4cff19227b..44d2c62a05 100644 --- a/examples/wsperf/generic.cpp +++ b/examples/wsperf/generic.cpp @@ -70,14 +70,15 @@ using wsperf::message_test; * mode can be used to test situations where you deliberately return incorrect * bytes in order to compare performance (ex: performance with/without masking) */ -message_test::message_test(wscmd::cmd& cmd) : case_handler(cmd) { - m_message_count = extract_number(cmd,"size"); - m_message_size = extract_number(cmd,"count"); - m_timeout = extract_number(cmd,"timeout"); - - m_binary = extract_bool(cmd,"binary"); - m_sync = extract_bool(cmd,"sync"); - +message_test::message_test(wscmd::cmd& cmd) + : case_handler(cmd), + m_message_size(extract_number(cmd,"size")), + m_message_count(extract_number(cmd,"count")), + m_timeout(extract_number(cmd,"timeout")), + m_binary(extract_bool(cmd,"binary")), + m_sync(extract_bool(cmd,"sync")), + m_acks(0) +{ if (cmd.args["correctness"] == "exact") { m_mode = EXACT; } else if (cmd.args["correctness"] == "length") {