mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-16 14:08:59 +07:00
initial basic utils
This commit is contained in:
@@ -8,3 +8,32 @@
|
||||
|
||||
#include "../catch/catch.hpp"
|
||||
#include <enduro2d/enduro2d.hpp>
|
||||
|
||||
namespace e2d_untests
|
||||
{
|
||||
using namespace e2d;
|
||||
|
||||
template < typename TimeTag >
|
||||
class verbose_profiler : noncopyable {
|
||||
public:
|
||||
verbose_profiler(const str& desc)
|
||||
: desc_(desc) {
|
||||
begin_ = time::now<TimeTag>();
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
void done(const T& result) const {
|
||||
const auto end = time::now<TimeTag>();
|
||||
std::printf(
|
||||
"result: %s, time: %s, desc: %s\n",
|
||||
std::to_string(result).c_str(),
|
||||
std::to_string((end - begin_).value).c_str(),
|
||||
desc_.c_str());
|
||||
}
|
||||
private:
|
||||
str desc_;
|
||||
unit<i64, TimeTag> begin_;
|
||||
};
|
||||
using verbose_profiler_us = verbose_profiler<microseconds_tag>;
|
||||
using verbose_profiler_ms = verbose_profiler<milliseconds_tag>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user