diff --git a/examples/broadcast_server_tls/broadcast_admin.html b/examples/broadcast_server_tls/broadcast_admin.html index 0e6c917278..0d18cd6155 100644 --- a/examples/broadcast_server_tls/broadcast_admin.html +++ b/examples/broadcast_server_tls/broadcast_admin.html @@ -15,7 +15,7 @@ var options = {"console_enabled": true}; var ws; var url; -var data2 = [], total_points = 60; +var data2 = [], total_points = 240; var stale_data = null; var message_history = []; diff --git a/examples/broadcast_server_tls/broadcast_server_tls.cpp b/examples/broadcast_server_tls/broadcast_server_tls.cpp index ae1dffcd7c..6ea4cab6a2 100644 --- a/examples/broadcast_server_tls/broadcast_server_tls.cpp +++ b/examples/broadcast_server_tls/broadcast_server_tls.cpp @@ -97,7 +97,7 @@ public: void on_open(connection_ptr connection) { if (!m_timer) { m_timer.reset(new boost::asio::deadline_timer(connection->get_io_service(),boost::posix_time::seconds(0))); - m_timer->expires_from_now(boost::posix_time::milliseconds(500)); + m_timer->expires_from_now(boost::posix_time::milliseconds(250)); m_timer->async_wait(boost::bind(&type::on_timer,this,boost::asio::placeholders::error)); m_last_time = boost::posix_time::microsec_clock::local_time(); } @@ -369,7 +369,7 @@ public: //m_data = 0; //} - m_timer->expires_from_now(boost::posix_time::milliseconds(500)); + m_timer->expires_from_now(boost::posix_time::milliseconds(250)); m_timer->async_wait(boost::bind(&type::on_timer,this,boost::asio::placeholders::error)); } diff --git a/examples/stress_client/stress_client.cpp b/examples/stress_client/stress_client.cpp index e11776de56..e9f56b51ea 100644 --- a/examples/stress_client/stress_client.cpp +++ b/examples/stress_client/stress_client.cpp @@ -61,7 +61,9 @@ public: typedef stress_client_handler type; typedef plain_endpoint_type::connection_ptr connection_ptr; - stress_client_handler(int num_connections) : m_connections(num_connections) { + stress_client_handler(int num_connections) + : m_connections_max(num_connections), + m_connections_cur(0) { } @@ -71,12 +73,22 @@ public: m_timer->expires_from_now(boost::posix_time::milliseconds(250)); m_timer->async_wait(boost::bind(&type::on_timer,this,connection,boost::asio::placeholders::error)); } + + m_connections_cur++; + + if (m_connections_cur == m_connections_max) { + boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time(); + boost::posix_time::time_period period(m_start_time,now); + int ms = period.length().total_milliseconds(); + + std::cout << "Started " << m_connections_cur << " in " << ms << "ms" << " (" << m_connections_cur/(ms/1000.0) << "/s)" << std::endl; + } } void on_message(connection_ptr connection, websocketpp::message::data_ptr msg) { m_msg_stats[websocketpp::md5_hash_hex(msg->get_payload())]++; - if (m_msg_stats[websocketpp::md5_hash_hex(msg->get_payload())] == m_connections) { + if (m_msg_stats[websocketpp::md5_hash_hex(msg->get_payload())] == m_connections_max) { send_stats_update(connection); } @@ -102,6 +114,8 @@ public: void on_close(connection_ptr connection) { m_timer->cancel(); } + + boost::posix_time::ptime m_start_time; private: void send_stats_update(connection_ptr connection) { if (m_msg_stats.empty()) { @@ -126,7 +140,8 @@ private: m_msg_stats.clear(); } - int m_connections; + int m_connections_max; + int m_connections_cur; std::map m_msg_stats; boost::shared_ptr m_timer; }; @@ -197,6 +212,7 @@ int main(int argc, char* argv[]) { std::cout << "launching " << num_connections << " connections to " << uri << " in batches of " << batch_size << std::endl; + boost::dynamic_pointer_cast(handler)->m_start_time = boost::posix_time::microsec_clock::local_time(); for (int i = 0; i < num_connections-1; i++) { if (i % batch_size == 0) { //sleep(1);