From 11e00a8dedd8f430f6528d2852169d134c17367a Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 3 Jul 2023 16:04:17 +1000 Subject: Change debug render time logging to use microseconds --- source/core/StarTime.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/core/StarTime.cpp') diff --git a/source/core/StarTime.cpp b/source/core/StarTime.cpp index abb6aae..622ea50 100644 --- a/source/core/StarTime.cpp +++ b/source/core/StarTime.cpp @@ -20,6 +20,10 @@ int64_t Time::monotonicMilliseconds() { return ticksToMilliseconds(monotonicTicks(), monotonicTickFrequency()); } +int64_t Time::monotonicMicroseconds() { + return ticksToMicroseconds(monotonicTicks(), monotonicTickFrequency()); +} + String Time::printDuration(double time) { String hours; String minutes; @@ -58,6 +62,11 @@ int64_t Time::ticksToMilliseconds(int64_t ticks, int64_t tickFrequency) { return (ticks + ticksPerMs / 2) / ticksPerMs; } +int64_t Time::ticksToMicroseconds(int64_t ticks, int64_t tickFrequency) { + int64_t ticksPerUs = (tickFrequency + 500000) / 1000000; + return (ticks + ticksPerUs / 2) / ticksPerUs; +} + int64_t Time::secondsToTicks(double seconds, int64_t tickFrequency) { return round(seconds * tickFrequency); } @@ -66,6 +75,10 @@ int64_t Time::millisecondsToTicks(int64_t milliseconds, int64_t tickFrequency) { return milliseconds * ((tickFrequency + 500) / 1000); } +int64_t Time::microsecondsToTicks(int64_t microseconds, int64_t tickFrequency) { + return microseconds * ((tickFrequency + 500000) / 1000000); +} + Clock::Clock(bool start) { m_elapsedTicks = 0; m_running = false; -- cgit v1.2.3