(ws connect) display statistics about how much time it takes to stop the connection / cf #168
This commit is contained in:
parent
179e17895d
commit
37cb2cc266
@ -1,6 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [9.0.3] - 2020-03-24
|
||||||
|
|
||||||
|
(ws connect) display statistics about how much time it takes to stop the connection
|
||||||
|
|
||||||
## [9.0.2] - 2020-03-24
|
## [9.0.2] - 2020-03-24
|
||||||
|
|
||||||
(socket) works with unique_ptr<Socket> instead of shared_ptr<Socket> in many places
|
(socket) works with unique_ptr<Socket> instead of shared_ptr<Socket> in many places
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "9.0.2"
|
#define IX_WEBSOCKET_VERSION "9.0.3"
|
||||||
|
@ -35,6 +35,7 @@ endif()
|
|||||||
add_executable(ws
|
add_executable(ws
|
||||||
../third_party/msgpack11/msgpack11.cpp
|
../third_party/msgpack11/msgpack11.cpp
|
||||||
${JSONCPP_SOURCES}
|
${JSONCPP_SOURCES}
|
||||||
|
IXBench.cpp
|
||||||
|
|
||||||
ws_http_client.cpp
|
ws_http_client.cpp
|
||||||
ws_ping_pong.cpp
|
ws_ping_pong.cpp
|
||||||
|
44
ws/IXBench.cpp
Normal file
44
ws/IXBench.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* IXBench.cpp
|
||||||
|
* Author: Benjamin Sergeant
|
||||||
|
* Copyright (c) 2017-2020 Machine Zone, Inc. All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "IXBench.h"
|
||||||
|
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
namespace ix
|
||||||
|
{
|
||||||
|
Bench::Bench(const std::string& description)
|
||||||
|
: _description(description)
|
||||||
|
, _start(std::chrono::system_clock::now())
|
||||||
|
, _reported(false)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bench::~Bench()
|
||||||
|
{
|
||||||
|
if (!_reported)
|
||||||
|
{
|
||||||
|
report();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bench::report()
|
||||||
|
{
|
||||||
|
auto now = std::chrono::system_clock::now();
|
||||||
|
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(now - _start);
|
||||||
|
|
||||||
|
_ms = milliseconds.count();
|
||||||
|
spdlog::info("{} completed in {} ms", _description, _ms);
|
||||||
|
|
||||||
|
_reported = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Bench::getDuration() const
|
||||||
|
{
|
||||||
|
return _ms;
|
||||||
|
}
|
||||||
|
}
|
28
ws/IXBench.h
Normal file
28
ws/IXBench.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* IXBench.h
|
||||||
|
* Author: Benjamin Sergeant
|
||||||
|
* Copyright (c) 2017-2020 Machine Zone, Inc. All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <chrono>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace ix
|
||||||
|
{
|
||||||
|
class Bench
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Bench(const std::string& description);
|
||||||
|
~Bench();
|
||||||
|
|
||||||
|
void report();
|
||||||
|
uint64_t getDuration() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string _description;
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> _start;
|
||||||
|
uint64_t _ms;
|
||||||
|
bool _reported;
|
||||||
|
};
|
||||||
|
}
|
@ -4,10 +4,12 @@
|
|||||||
* Copyright (c) 2017-2018 Machine Zone, Inc. All rights reserved.
|
* Copyright (c) 2017-2018 Machine Zone, Inc. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "linenoise.hpp"
|
#include "IXBench.h"
|
||||||
#include <ixwebsocket/IXSocket.h>
|
#include <ixwebsocket/IXSocket.h>
|
||||||
#include <ixwebsocket/IXSocketTLSOptions.h>
|
#include <ixwebsocket/IXSocketTLSOptions.h>
|
||||||
#include <ixwebsocket/IXWebSocket.h>
|
#include <ixwebsocket/IXWebSocket.h>
|
||||||
|
|
||||||
|
#include "linenoise.hpp"
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -129,7 +131,10 @@ namespace ix
|
|||||||
|
|
||||||
void WebSocketConnect::stop()
|
void WebSocketConnect::stop()
|
||||||
{
|
{
|
||||||
_webSocket.stop();
|
{
|
||||||
|
Bench bench("ws_connect: stop connection");
|
||||||
|
_webSocket.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketConnect::start()
|
void WebSocketConnect::start()
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
* Copyright (c) 2017-2018 Machine Zone, Inc. All rights reserved.
|
* Copyright (c) 2017-2018 Machine Zone, Inc. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <chrono>
|
#include "IXBench.h"
|
||||||
#include <condition_variable>
|
|
||||||
#include <fstream>
|
|
||||||
#include <ixcrypto/IXBase64.h>
|
#include <ixcrypto/IXBase64.h>
|
||||||
#include <ixcrypto/IXHash.h>
|
#include <ixcrypto/IXHash.h>
|
||||||
#include <ixcrypto/IXUuid.h>
|
#include <ixcrypto/IXUuid.h>
|
||||||
@ -14,6 +13,10 @@
|
|||||||
#include <ixwebsocket/IXSocketTLSOptions.h>
|
#include <ixwebsocket/IXSocketTLSOptions.h>
|
||||||
#include <ixwebsocket/IXWebSocket.h>
|
#include <ixwebsocket/IXWebSocket.h>
|
||||||
#include <msgpack11/msgpack11.hpp>
|
#include <msgpack11/msgpack11.hpp>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <fstream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -195,48 +198,6 @@ namespace ix
|
|||||||
_webSocket.start();
|
_webSocket.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bench
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Bench(const std::string& description)
|
|
||||||
: _description(description)
|
|
||||||
, _start(std::chrono::system_clock::now())
|
|
||||||
, _reported(false)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
~Bench()
|
|
||||||
{
|
|
||||||
if (!_reported)
|
|
||||||
{
|
|
||||||
report();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void report()
|
|
||||||
{
|
|
||||||
auto now = std::chrono::system_clock::now();
|
|
||||||
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(now - _start);
|
|
||||||
|
|
||||||
_ms = milliseconds.count();
|
|
||||||
spdlog::info("{} completed in {} ms", _description, _ms);
|
|
||||||
|
|
||||||
_reported = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t getDuration() const
|
|
||||||
{
|
|
||||||
return _ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string _description;
|
|
||||||
std::chrono::time_point<std::chrono::system_clock> _start;
|
|
||||||
uint64_t _ms;
|
|
||||||
bool _reported;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool WebSocketSender::sendMessage(const std::string& filename, bool throttle)
|
bool WebSocketSender::sendMessage(const std::string& filename, bool throttle)
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> content;
|
std::vector<uint8_t> content;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user