summaryrefslogtreecommitdiff
path: root/src/helpers/time/Timer.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-04-16 01:37:48 +0100
committerVaxry <vaxry@vaxry.net>2025-04-16 01:37:48 +0100
commit877fb5b93ada9b25b4d2f5ca5f69370fa345f1ac (patch)
tree5b52ad19c695590ae50c7adae06b8e3aeccf34c1 /src/helpers/time/Timer.cpp
parent0e521788bcc414c9cf81648d3167757d83deb60f (diff)
time: move to stl's clocks and move timer
Diffstat (limited to 'src/helpers/time/Timer.cpp')
-rw-r--r--src/helpers/time/Timer.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/helpers/time/Timer.cpp b/src/helpers/time/Timer.cpp
new file mode 100644
index 00000000..95f75441
--- /dev/null
+++ b/src/helpers/time/Timer.cpp
@@ -0,0 +1,23 @@
+#include "Timer.hpp"
+
+#define chr std::chrono
+
+void CTimer::reset() {
+ m_lastReset = Time::steadyNow();
+}
+
+Time::steady_dur CTimer::getDuration() {
+ return Time::steadyNow() - m_lastReset;
+}
+
+float CTimer::getMillis() {
+ return chr::duration_cast<chr::microseconds>(getDuration()).count() / 1000.F;
+}
+
+float CTimer::getSeconds() {
+ return chr::duration_cast<chr::milliseconds>(getDuration()).count() / 1000.F;
+}
+
+const Time::steady_tp& CTimer::chrono() const {
+ return m_lastReset;
+} \ No newline at end of file