diff --git a/examples/wsperf/Makefile b/examples/wsperf/Makefile index 08e8356fb7..0dcc56720e 100644 --- a/examples/wsperf/Makefile +++ b/examples/wsperf/Makefile @@ -3,7 +3,7 @@ BOOST_INCLUDE_PATH ?= /usr/local/include WEBSOCKETPP_PATH ?= ../../ CPP11 ?= -CFLAGS = -Wall -O2 $(CPP11) -I$(BOOST_INCLUDE_PATH) +CFLAGS = -Wall -O3 $(CPP11) -I$(BOOST_INCLUDE_PATH) LDFLAGS = -L$(BOOST_LIB_PATH) CXX ?= c++ @@ -23,10 +23,7 @@ else LDFLAGS := $(LDFLAGS) $(WEBSOCKETPP_PATH)/libwebsocketpp.a $(BOOST_LIB_PATH)/libboost_system.a $(BOOST_LIB_PATH)/libboost_date_time.a $(BOOST_LIB_PATH)/libboost_regex.a $(BOOST_LIB_PATH)/libboost_thread.a $(BOOST_LIB_PATH)/libboost_random.a $(BOOST_LIB_PATH)/libboost_chrono.a $(BOOST_LIB_PATH)/libboost_program_options.a $(darwinlibs) endif -wsperf: wsperf.o - $(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS) - -wsperf_client: wsperf_client.o +wsperf: wsperf.o request.o case.o generic.o wscmd.o $(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS) %.o: %.cpp diff --git a/examples/wsperf/case.cpp b/examples/wsperf/case.cpp index f7a48e1073..6c2a401da7 100644 --- a/examples/wsperf/case.cpp +++ b/examples/wsperf/case.cpp @@ -68,19 +68,22 @@ case_handler::case_handler(wscmd::cmd& cmd) { /// Starts a test by starting the timeout timer and marking the start time void case_handler::start(connection_ptr con, uint64_t timeout) { - m_timer.reset(new boost::asio::deadline_timer( - con->get_io_service(), - boost::posix_time::seconds(0)) - ); - m_timer->expires_from_now(boost::posix_time::milliseconds(timeout)); - m_timer->async_wait( - boost::bind( - &type::on_timer, - this, - con, - boost::asio::placeholders::error - ) - ); + if (timeout > 0) { + m_timer.reset(new boost::asio::deadline_timer( + con->get_io_service(), + boost::posix_time::seconds(0)) + ); + + m_timer->expires_from_now(boost::posix_time::milliseconds(timeout)); + m_timer->async_wait( + boost::bind( + &type::on_timer, + this, + con, + boost::asio::placeholders::error + ) + ); + } m_start = boost::chrono::steady_clock::now(); } @@ -106,6 +109,8 @@ void case_handler::end(connection_ptr con) { double total = 0; double seconds = 0; + m_timer->cancel(); + // TODO: handle weird sizes and error conditions better if (m_end.size() > m_quantile_count) { boost::chrono::steady_clock::time_point last = m_start; diff --git a/examples/wsperf/generic.cpp b/examples/wsperf/generic.cpp index 9082caa460..4cff19227b 100644 --- a/examples/wsperf/generic.cpp +++ b/examples/wsperf/generic.cpp @@ -122,7 +122,6 @@ void message_test::on_message(connection_ptr con,websocketpp::message::data_ptr mark(); } else { mark(); - m_timer->cancel(); m_msg.reset(); m_pass = FAIL; @@ -131,7 +130,6 @@ void message_test::on_message(connection_ptr con,websocketpp::message::data_ptr if (m_acks == m_message_count) { m_pass = PASS; - m_timer->cancel(); m_msg.reset(); this->end(con); } else if (m_sync && m_pass == RUNNING) { diff --git a/websocketpp.xcodeproj/project.pbxproj b/websocketpp.xcodeproj/project.pbxproj index 55db529ef1..5f525eb982 100644 --- a/websocketpp.xcodeproj/project.pbxproj +++ b/websocketpp.xcodeproj/project.pbxproj @@ -17,6 +17,8 @@ B61A51CF14DC276300456432 /* libboost_system.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B6DF1CBC1434AE070029A1B1 /* libboost_system.dylib */; }; B61A51D014DC276300456432 /* libboost_thread.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B682888E14374689002BA48B /* libboost_thread.dylib */; }; B62A5A7214775ECF005F9EB0 /* libwebsocketpp.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B6DF1C721434A8280029A1B1 /* libwebsocketpp.dylib */; }; + B649759E150BF6C700BE17D1 /* wscmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B649759D150BA96100BE17D1 /* wscmd.cpp */; }; + B649759F150BF6D200BE17D1 /* libboost_program_options.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B6FE8CEB145A0F1900B32547 /* libboost_program_options.dylib */; }; B653A715148A607D004D7BD9 /* hybi_header.hpp in Headers */ = {isa = PBXBuildFile; fileRef = B653A714148A607D004D7BD9 /* hybi_header.hpp */; }; B653A716148A607D004D7BD9 /* hybi_header.hpp in Headers */ = {isa = PBXBuildFile; fileRef = B653A714148A607D004D7BD9 /* hybi_header.hpp */; }; B653A719148AB555004D7BD9 /* hybi_header.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B653A718148AB555004D7BD9 /* hybi_header.cpp */; }; @@ -515,6 +517,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + B649759F150BF6D200BE17D1 /* libboost_program_options.dylib in Frameworks */, B6E7E78B150553D000394909 /* libboost_chrono.dylib in Frameworks */, B6E7E789150553A500394909 /* libcrypto.dylib in Frameworks */, B6E7E7881505539E00394909 /* libssl.dylib in Frameworks */, @@ -1354,6 +1357,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + B649759E150BF6C700BE17D1 /* wscmd.cpp in Sources */, B6E7E77E1505536500394909 /* wsperf.cpp in Sources */, B6E7E7801505536500394909 /* case.cpp in Sources */, B6E7E7811505536500394909 /* generic.cpp in Sources */,