FPL provides a couple of functions for measuring elapsed time, used for profiling, delta time calculations and timeouts.
- Note
- These functions are meant for delta measurements only. They are not tied to a calendar date and the starting point is undefined (OS start, system start, etc.).
To query the current calendar date and time, see Query Date & Time instead.
High precision measurement
For the most precise time measurement, use fplTimestampQuery() to capture a fplTimestamp.
A fplTimestamp is an opaque value - it only has meaning when compared against another timestamp.
To get the elapsed time between two timestamps, call fplTimestampElapsed() . It returns the delta in seconds as fplSeconds (a 64-bit double).
fpl_common_api void fplConsoleFormatOut(const char *format,...)
Writes the given formatted text to the standard output console buffer.
fpl_platform_api fplTimestamp fplTimestampQuery(void)
Gets the current fplTimestamp with most precision, used for time delta measurements only.
double fplSeconds
A type definition for seconds (64-bit).
fpl_platform_api fplSeconds fplTimestampElapsed(const fplTimestamp start, const fplTimestamp finish)
Gets the delta value from two fplTimestamp values in seconds.
Stores a timestamp, used for delta measurements only.
This is the recommended way to compute frame delta times in a game loop:
while (running) {
last = now;
}
Low precision measurement
For simple, less precise measurements you can use fplMillisecondsQuery() .
It returns the current system clock in milliseconds as fplMilliseconds (a 64-bit unsigned integer), counted from some fixed but undefined starting point.
uint64_t fplMilliseconds
A type definition for milliseconds (64-bit).
fpl_platform_api fplMilliseconds fplMillisecondsQuery(void)
Gets the current system clock in milliseconds, since some fixed starting point (OS start,...
Timeout values
A number of FPL functions (mutexes, signals, semaphores, etc.) accept a timeout argument expressed as a fplTimeoutValue.
This is a timeout in milliseconds. To wait indefinitely, pass the FPL_TIMEOUT_INFINITE constant.
uint32_t fplTimeoutValue
A type definition for a timeout value in milliseconds.
#define FPL_TIMEOUT_INFINITE
Infinite timeout constant.
Notes