Using stopwatch for precise timing and delta time measurements.
Using stopwatch for precise timing and delta time measurements.A stopwatch tracks both total elapsed time and delta time (time since last measurement). This is essential for frame-independent game logic, animation, and performance profiling.
#define BJ_AUTOMAIN_CALLBACKS
int bj_app_begin(
void** user_data,
int argc,
char* argv[]) {
(void)user_data; (void)argc; (void)argv;
return bj_callback_exit_error;
}
return bj_callback_continue;
}
(void)user_data;
bj_trace(
"Elapsed: %.3lf s | Delay: %.3lf s", elapsed, delay);
return elapsed >= 3.0 ? bj_callback_exit_success : bj_callback_continue;
}
(void)user_data;
return status;
}
int bj_app_begin(void **user_data, int argc, char *argv[])
Definition audio_pcm.c:25
int bj_app_iterate(void *user_data)
Definition audio_pcm.c:60
int bj_app_end(void *user_data, int status)
Definition audio_pcm.c:84
#define bj_trace(...)
Log a message using the BJ_LOG_TRACE level.
Definition log.h:77
bj_bool bj_begin(int systems, struct bj_error **error)
Initializes the system.
void bj_end(void)
De-initializes the system.
@ BJ_NO_SYSTEM
Definition system.h:18
void bj_sleep(int milliseconds)
Suspends the current thread for a specified duration.
double bj_stopwatch_delay(const struct bj_stopwatch *stopwatch)
Returns the time in seconds since the last step.
void bj_step_stopwatch(struct bj_stopwatch *stopwatch)
Records a step/checkpoint in time.
double bj_stopwatch_elapsed(const struct bj_stopwatch *stopwatch)
Returns the elapsed time in seconds since the stopwatch was reset.
Structure representing a simple stopwatch.
Definition time.h:97
Logging utility functions.
Portable main substitution and application callback facilities.
static bj_stopwatch p_stopwatch
Definition stopwatch.c:16
Header file for system interactions.
Header file for time manipulation utilities.