3#include "../FoundationBase.h"
9#if defined(__EMSCRIPTEN__)
10 typedef double TimePerf;
13 typedef int64_t TimePerf;
18 COGSFOUNDATION_API TimePerf
perfTime();
24 COGSFOUNDATION_API Time currentTimeReference();
28 COGSFOUNDATION_API int64_t perfTimeToMilliseconds(TimePerf time);
29 COGSFOUNDATION_API
double perfTimeToSeconds(TimePerf time);
31 COGSFOUNDATION_API int64_t currentTimeToMicroseconds(Time time);
32 COGSFOUNDATION_API int64_t currentTimeToMilliseconds(Time time);
33 COGSFOUNDATION_API
double currentTimeToSeconds(Time time);
48 static inline Timer startNew()
67 int64_t elapsedMilliseconds() {
if(running) stopTime =
Cogs::perfTime();
return perfTimeToMilliseconds(scalePerfTime(stopTime - startTime)); }
68 double elapsedSeconds() {
if(running) stopTime =
Cogs::perfTime();
return perfTimeToSeconds(scalePerfTime(stopTime - startTime)); }
70 static int64_t currentTimeMicroseconds() {
return currentTimeToMicroseconds(
currentTime()); }
71 static int64_t currentTimeMilliseconds() {
return currentTimeToMilliseconds(
currentTime()); }
73#if defined(__EMSCRIPTEN__)
74 void setScale(int64_t s) { scale =
static_cast<double>(s) / 1000.0; }
75 void resetScale() { scale = 1.0; }
76 int64_t getScale()
const {
return static_cast<int64_t
>(1000.0 * scale); }
77 TimePerf scalePerfTime(TimePerf time) {
return time*scale; }
79 void setScale(int64_t s) { scale = s; }
80 void resetScale() { scale = 1000; }
81 int64_t getScale()
const {
return scale; }
82 TimePerf scalePerfTime(TimePerf time) {
return time*scale/1000; }
86 TimePerf startTime = {};
87 TimePerf stopTime = {};
88#if defined(__EMSCRIPTEN__)
High-resolution performance timer.
Contains all Cogs related functionality.
COGSFOUNDATION_API int64_t perfTimeToMicroseconds(TimePerf time)
Convertion functions for timestamps.
COGSFOUNDATION_API TimePerf perfTime()
High resolution performance timer. Returns an implementation defined absolute timestamp,...
COGSFOUNDATION_API TimePerf perfTimeReference()
Functions that provide a reference time point at the start of the application startup....
COGSFOUNDATION_API Time currentTime()
High resolution clock time (NTP / UTC time). Returns an implementation defined absolute timestamp,...