BRL-CAD
Loading...
Searching...
No Matches
Bu_datetime

Cross platform wrapper for timing functionality. More...

Files

file  datetime.h
 

Functions

int64_t bu_gettime (void)
 
int64_t bu_timer_cpu (void)
 
int64_t bu_timer_cpu_thread (void)
 
void bu_utctime (struct bu_vls *utc_result, const int64_t time_val)
 

Detailed Description

Cross platform wrapper for timing functionality.

Function Documentation

◆ bu_gettime()

int64_t bu_gettime ( void  )
extern

Returns a microsecond-accurate wall-clock time counter.

Example use:

int64_t start = bu_gettime();
double elapsed = bu_gettime() - start;
double seconds = elapsed / 1000000.0;
printf("time: %.2f\n", seconds);
Definition dvec.h:74
int64_t bu_gettime(void)

◆ bu_timer_cpu()

int64_t bu_timer_cpu ( void  )
extern

Returns a high-resolution CPU (user+system) time counter for the current process, in nanoseconds.

Unlike bu_gettime(), this value is not a wall-clock or epoch timestamp. It measures CPU time consumed by the process across all threads. Returns -1 if a process CPU timer is not available on the platform.

◆ bu_timer_cpu_thread()

int64_t bu_timer_cpu_thread ( void  )
extern

Returns a high-resolution CPU (user+system) time counter for the current thread, in nanoseconds.

This is useful for profiling small regions of threaded work without charging scheduler preemption or other threads' work to the measured interval. Returns -1 if a current-thread CPU timer is not available on the platform.

◆ bu_utctime()

void bu_utctime ( struct bu_vls utc_result,
const int64_t  time_val 
)

Evaluate the time_t input as UTC time in ISO format.

The UTC time is written into the user-provided bu_vls struct and is also returned and guaranteed to be a non-null result, returning a static "NULL" UTC time if an error is encountered.