1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Refactor profiler and related classes

This commit is contained in:
sfan5 2024-04-10 23:56:34 +02:00
parent 5a07f5a652
commit 72eeb9fecb
7 changed files with 133 additions and 132 deletions

View file

@ -23,12 +23,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h"
#include <ostream>
TimeTaker::TimeTaker(const std::string &name, u64 *result, TimePrecision prec)
void TimeTaker::start()
{
m_name = name;
m_result = result;
m_precision = prec;
m_time1 = porting::getTime(prec);
m_time1 = porting::getTime(m_precision);
}
u64 TimeTaker::stop(bool quiet)
@ -39,15 +36,8 @@ u64 TimeTaker::stop(bool quiet)
(*m_result) += dtime;
} else {
if (!quiet) {
static const char* const units[] = {
"s" /* PRECISION_SECONDS */,
"ms" /* PRECISION_MILLI */,
"us" /* PRECISION_MICRO */,
"ns" /* PRECISION_NANO */,
};
infostream << m_name << " took "
<< dtime << units[m_precision]
<< std::endl;
<< dtime << TimePrecision_units[m_precision] << std::endl;
}
}
m_running = false;