mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-14 09:05:19 +02:00
Add varying levels of precision to TimeTaker
This commit is contained in:
@@ -23,19 +23,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "../log.h"
|
||||
#include <ostream>
|
||||
|
||||
TimeTaker::TimeTaker(const char *name, u32 *result)
|
||||
TimeTaker::TimeTaker(const char *name, u32 *result, TimePrecision prec)
|
||||
{
|
||||
m_name = name;
|
||||
m_result = result;
|
||||
m_running = true;
|
||||
m_time1 = getTimeMs();
|
||||
m_precision = prec;
|
||||
m_time1 = getTime(prec);
|
||||
}
|
||||
|
||||
u32 TimeTaker::stop(bool quiet)
|
||||
{
|
||||
if(m_running)
|
||||
{
|
||||
u32 time2 = getTimeMs();
|
||||
u32 time2 = getTime(m_precision);
|
||||
u32 dtime = time2 - m_time1;
|
||||
if(m_result != NULL)
|
||||
{
|
||||
@@ -52,9 +53,9 @@ u32 TimeTaker::stop(bool quiet)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 TimeTaker::getTime()
|
||||
u32 TimeTaker::getTimerTime()
|
||||
{
|
||||
u32 time2 = getTimeMs();
|
||||
u32 time2 = getTime(m_precision);
|
||||
u32 dtime = time2 - m_time1;
|
||||
return dtime;
|
||||
}
|
||||
|
Reference in New Issue
Block a user