VoxelEngine/src/util/timeutil.cpp
2024-02-26 15:12:02 +03:00

29 lines
798 B
C++

#include "timeutil.h"
#include <iostream>
using std::chrono::high_resolution_clock;
using std::chrono::duration_cast;
using std::chrono::microseconds;
timeutil::Timer::Timer() {
start = high_resolution_clock::now();
}
int64_t timeutil::Timer::stop() {
return duration_cast<microseconds>(high_resolution_clock::now()-start).count();
}
timeutil::ScopeLogTimer::ScopeLogTimer(long long id) : scopeid_(id) {}
timeutil::ScopeLogTimer::~ScopeLogTimer() {
std::cout << "Scope "<< scopeid_ <<" finished in "<< ScopeLogTimer::stop() << " micros. \n";
}
void timeutil::from_value(float value, int& hour, int& minute, int& second) {
value *= 24;
hour = value;
value *= 60;
minute = int(value) % 60;
value *= 60;
second = int(value) % 60;
}