SAF
Loading...
Searching...
No Matches
timer.h File Reference
#include <stdint.h>

Go to the source code of this file.

Macros

#define TIMER_API   extern
 

Typedefs

typedef uint64_t tick_t
 Tick type.
 
typedef double deltatime_t
 Deltatime type (float or double)
 

Functions

TIMER_API int timer_lib_initialize (void)
 
TIMER_API void timer_lib_shutdown (void)
 
TIMER_API tick_t timer_current (void)
 
TIMER_API deltatime_t timer_elapsed (const tick_t t)
 
TIMER_API tick_t timer_elapsed_ticks (const tick_t t)
 
TIMER_API tick_t timer_ticks_per_second (void)
 
TIMER_API deltatime_t timer_ticks_to_seconds (const tick_t dt)
 
TIMER_API tick_t timer_system (void)
 

Detailed Description

Time measurements

Definition in file timer.h.

Macro Definition Documentation

◆ TIMER_API

#define TIMER_API   extern

Definition at line 22 of file timer.h.

Typedef Documentation

◆ deltatime_t

typedef double deltatime_t

Deltatime type (float or double)

Definition at line 41 of file timer.h.

◆ tick_t

typedef uint64_t tick_t

Tick type.

Definition at line 35 of file timer.h.

Function Documentation

◆ timer_current()

TIMER_API tick_t timer_current ( void )

Get current timestamp, in ticks of system-specific frequency (queryable with timer_ticks_per_second), measured from some system-specific base timestamp and not in sync with other timestamps

Returns
Current timestamp

◆ timer_elapsed()

TIMER_API deltatime_t timer_elapsed ( const tick_t t)

Get elapsed time since given timestamp

Parameters
tTimestamp
Returns
Number of seconds elapsed

◆ timer_elapsed_ticks()

TIMER_API tick_t timer_elapsed_ticks ( const tick_t t)

Get elapsed ticks since given timestamp

Parameters
tTimestamp
Returns
Number of ticks elapsed

◆ timer_lib_initialize()

TIMER_API int timer_lib_initialize ( void )

Initialize timer library

◆ timer_lib_shutdown()

TIMER_API void timer_lib_shutdown ( void )

Shutdown timer library

◆ timer_system()

TIMER_API tick_t timer_system ( void )

Get system time, in milliseconds since the epoch (UNIX time)

Returns
Current timestamp, in milliseconds

◆ timer_ticks_per_second()

TIMER_API tick_t timer_ticks_per_second ( void )

Get timer frequency, as number of ticks per second

Returns
Ticks per second

◆ timer_ticks_to_seconds()

TIMER_API deltatime_t timer_ticks_to_seconds ( const tick_t dt)

Get ticks as seconds (effectively calculating ticks/timer_ticks_per_second())

Parameters
dtDeltatime in ticks
Returns
Deltatime in seconds