move IXBench code under ixwebsocker folder
This commit is contained in:
@ -35,7 +35,6 @@ endif()
|
||||
add_executable(ws
|
||||
../third_party/msgpack11/msgpack11.cpp
|
||||
${JSONCPP_SOURCES}
|
||||
IXBench.cpp
|
||||
|
||||
ws_http_client.cpp
|
||||
ws_ping_pong.cpp
|
||||
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
} // namespace ix
|
28
ws/IXBench.h
28
ws/IXBench.h
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* IXBench.h
|
||||
* Author: Benjamin Sergeant
|
||||
* Copyright (c) 2017-2020 Machine Zone, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
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;
|
||||
};
|
||||
} // namespace ix
|
Reference in New Issue
Block a user