Make util::profiler use the logging system
This commit is contained in:
parent
8ea508ee20
commit
abd40bfa4d
2 changed files with 18 additions and 8 deletions
|
|
@ -1,26 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/util/clock.hpp>
|
||||
#include <psemek/util/pretty_print.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace psemek::util
|
||||
{
|
||||
|
||||
struct profiler
|
||||
{
|
||||
profiler(std::string name)
|
||||
profiler(std::string_view name)
|
||||
: name_(std::move(name))
|
||||
{}
|
||||
|
||||
~ profiler()
|
||||
{
|
||||
std::cout << name_ << ": " << util::pretty(clock_.duration(), std::chrono::microseconds{1}) << "\n";
|
||||
}
|
||||
~ profiler();
|
||||
|
||||
private:
|
||||
std::string const name_;
|
||||
std::string_view const name_;
|
||||
util::clock<> clock_;
|
||||
};
|
||||
|
||||
|
|
|
|||
14
libs/util/source/profiler.cpp
Normal file
14
libs/util/source/profiler.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <psemek/util/profiler.hpp>
|
||||
#include <psemek/util/pretty_print.hpp>
|
||||
#include <psemek/log/log.hpp>
|
||||
|
||||
|
||||
namespace psemek::util
|
||||
{
|
||||
|
||||
profiler::~profiler()
|
||||
{
|
||||
log::info() << name_ << ": " << util::pretty(clock_.duration(), std::chrono::microseconds{1});
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue