Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
Time

Abstraction to usual system calls related to time. More...

Detailed Description

Functions

void bj_sleep (int milliseconds)
 Suspends the current thread for a specified duration.
 
double bj_get_time (void)
 Gets the current time in seconds.
 
uint64_t bj_get_time_counter (void)
 Gets the current raw high-resolution time counter.
 
uint64_t bj_get_time_frequency (void)
 Gets the frequency of the high-resolution time counter.
 

Function Documentation

◆ bj_get_time()

double bj_get_time ( void )

Returns the elapsed time in seconds since Banjo is initialized with bj_begin.

Returns
The current time in seconds as a double-precision value.
See also
bj_get_time_counter, bj_get_time_frequency, bj_sleep
Examples
audio_pcm.c, shaders.c, and time.c.

◆ bj_get_time_counter()

uint64_t bj_get_time_counter ( void )

This function returns a time counter in platform-dependent ticks. To convert the value to seconds, divide it by the result of bj_get_time_frequency or just call bj_get_time.

Returns
The current high-resolution time counter.
See also
bj_get_time, bj_get_time_frequency, bj_sleep

◆ bj_get_time_frequency()

uint64_t bj_get_time_frequency ( void )

This function returns the number of ticks per second of the high-resolution counter. It is used in conjunction with bj_get_time_counter to compute durations.

Returns
The frequency in ticks per second.
See also
bj_get_time, bj_get_time_counter, bj_sleep

◆ bj_sleep()

void bj_sleep ( int milliseconds)

This function puts the current thread to sleep for at least the specified number of milliseconds. The actual sleep duration may be longer depending on system timing.

Parameters
millisecondsThe number of milliseconds to sleep.
See also
bj_get_time, bj_get_time_counter, bj_get_time_frequency
Examples
bitmap_blit.c, drawing_2d.c, events.c, shaders.c, sprite_animation.c, and time.c.