mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-24 20:35:12 +00:00
util/profiler: Adjust to match coding guidelines
This commit is contained in:
parent
44b961f54a
commit
dce5c6b644
2 changed files with 19 additions and 19 deletions
|
@ -20,16 +20,16 @@
|
|||
#include "util-profiler.hpp"
|
||||
#include <iterator>
|
||||
|
||||
util::profiler::profiler() {}
|
||||
streamfx::util::profiler::profiler() {}
|
||||
|
||||
util::profiler::~profiler() {}
|
||||
streamfx::util::profiler::~profiler() {}
|
||||
|
||||
std::shared_ptr<util::profiler::instance> util::profiler::track()
|
||||
std::shared_ptr<streamfx::util::profiler::instance> streamfx::util::profiler::track()
|
||||
{
|
||||
return std::make_shared<util::profiler::instance>(shared_from_this());
|
||||
return std::make_shared<streamfx::util::profiler::instance>(shared_from_this());
|
||||
}
|
||||
|
||||
void util::profiler::track(std::chrono::nanoseconds duration)
|
||||
void streamfx::util::profiler::track(std::chrono::nanoseconds duration)
|
||||
{
|
||||
std::unique_lock<std::mutex> ul(_timings_lock);
|
||||
auto itr = _timings.find(duration);
|
||||
|
@ -40,7 +40,7 @@ void util::profiler::track(std::chrono::nanoseconds duration)
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t util::profiler::count()
|
||||
uint64_t streamfx::util::profiler::count()
|
||||
{
|
||||
uint64_t count = 0;
|
||||
|
||||
|
@ -57,7 +57,7 @@ uint64_t util::profiler::count()
|
|||
return count;
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds util::profiler::total_duration()
|
||||
std::chrono::nanoseconds streamfx::util::profiler::total_duration()
|
||||
{
|
||||
std::chrono::nanoseconds duration{0};
|
||||
|
||||
|
@ -74,7 +74,7 @@ std::chrono::nanoseconds util::profiler::total_duration()
|
|||
return duration;
|
||||
}
|
||||
|
||||
double_t util::profiler::average_duration()
|
||||
double_t streamfx::util::profiler::average_duration()
|
||||
{
|
||||
std::chrono::nanoseconds duration{0};
|
||||
uint64_t count = 0;
|
||||
|
@ -99,7 +99,7 @@ inline bool is_equal(T a, T b, T c)
|
|||
return (a == b) || ((a >= (b - c)) && (a <= (b + c)));
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds util::profiler::percentile(double_t percentile, bool by_time)
|
||||
std::chrono::nanoseconds streamfx::util::profiler::percentile(double_t percentile, bool by_time)
|
||||
{
|
||||
constexpr double_t edge = 0.00005;
|
||||
uint64_t calls = count();
|
||||
|
@ -144,11 +144,11 @@ std::chrono::nanoseconds util::profiler::percentile(double_t percentile, bool by
|
|||
return std::chrono::nanoseconds(-1);
|
||||
}
|
||||
|
||||
util::profiler::instance::instance(std::shared_ptr<util::profiler> parent)
|
||||
streamfx::util::profiler::instance::instance(std::shared_ptr<streamfx::util::profiler> parent)
|
||||
: _parent(parent), _start(std::chrono::high_resolution_clock::now())
|
||||
{}
|
||||
|
||||
util::profiler::instance::~instance()
|
||||
streamfx::util::profiler::instance::~instance()
|
||||
{
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto dur = end - _start;
|
||||
|
@ -157,12 +157,12 @@ util::profiler::instance::~instance()
|
|||
}
|
||||
}
|
||||
|
||||
void util::profiler::instance::cancel()
|
||||
void streamfx::util::profiler::instance::cancel()
|
||||
{
|
||||
_parent.reset();
|
||||
}
|
||||
|
||||
void util::profiler::instance::reparent(std::shared_ptr<util::profiler> parent)
|
||||
void streamfx::util::profiler::instance::reparent(std::shared_ptr<streamfx::util::profiler> parent)
|
||||
{
|
||||
_parent = parent;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
namespace util {
|
||||
class profiler : public std::enable_shared_from_this<util::profiler> {
|
||||
namespace streamfx::util {
|
||||
class profiler : public std::enable_shared_from_this<streamfx::util::profiler> {
|
||||
std::map<std::chrono::nanoseconds, size_t> _timings;
|
||||
std::mutex _timings_lock;
|
||||
|
||||
|
@ -49,7 +49,7 @@ namespace util {
|
|||
public:
|
||||
~profiler();
|
||||
|
||||
std::shared_ptr<class util::profiler::instance> track();
|
||||
std::shared_ptr<class streamfx::util::profiler::instance> track();
|
||||
|
||||
void track(std::chrono::nanoseconds duration);
|
||||
|
||||
|
@ -62,9 +62,9 @@ namespace util {
|
|||
std::chrono::nanoseconds percentile(double_t percentile, bool by_time = false);
|
||||
|
||||
public:
|
||||
static std::shared_ptr<util::profiler> create()
|
||||
static std::shared_ptr<streamfx::util::profiler> create()
|
||||
{
|
||||
return std::shared_ptr<util::profiler>{new profiler()};
|
||||
return std::shared_ptr<streamfx::util::profiler>{new profiler()};
|
||||
}
|
||||
};
|
||||
} // namespace util
|
||||
} // namespace streamfx::util
|
||||
|
|
Loading…
Reference in a new issue