Open
Description
openedon Oct 18, 2022
az_posix.c
implements the az_platform_clock_msec
by measuring CPU time, not wall time. This API isn't used today.
In ANSI C/POSIX, clock_t clock() is to approximate the CPU time spent in a process and the current naming creates confusion.
A few ways to fix this:
clock_gettime()
clock_getres()
. The problem is that POSIX doesn't guarantee availability of (all) timing functions. We'll need runtime code to discover enabled functionality.- Use the c
time()
epoch timer with 1 second accuracy.
Also, please consider the API breaking change to rename the API name to AZ_NODISCARD az_result az_platform_time_msec(int64_t* out_clock_msec)
to further reduce confusion on the purpose of the API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment