add Timer class

This commit is contained in:
2025-08-19 18:46:54 +02:00
parent ee39c1e429
commit 39580c15c5
2 changed files with 25 additions and 10 deletions

22
include/td/misc/Time.h Normal file
View File

@@ -0,0 +1,22 @@
#pragma once
#include <chrono>
namespace td {
class Timer {
private:
std::chrono::time_point<std::chrono::system_clock> m_LastTime;
public:
Timer() : m_LastTime(std::chrono::system_clock::now()) {}
float GetDelta() {
auto timeElapsed = std::chrono::system_clock::now() - m_LastTime;
float timeSeconds = std::chrono::duration<float, std::chrono::seconds::period>(timeElapsed).count();
m_LastTime = std::chrono::system_clock::now();
return timeSeconds;
}
};
} // namespace td