Skip to content

Time Measurement Profiling

Finalspace edited this page May 29, 2026 · 2 revisions

Table of Contents

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).

// Capture the starting timestamp
 start = ();

// ... do some work ...

// Capture the finishing timestamp and compute the delta
 finish = ();
 elapsed = (start, finish);

("Work took %f seconds\n", elapsed);

This is the recommended way to compute frame delta times in a game loop:

 last = ();
while (running) {
     now = ();
     deltaTime = (last, now);
    last = now;

    // Update the game using deltaTime
}

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.

 start = ();

// ... do some work ...

 elapsed = () - start;
("Work took %llu milliseconds\n", elapsed);

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.

// Wait at most 500 milliseconds
 timeout = 500;

// Wait forever
 infinite = ;

Notes

Final Platform Layer

Pages

Topics

Data Structures

Clone this wiki locally