This provides a portable set of time functions that are especially useful for porting other code or being wrapped by higher level c++ classes. Code has been divided broadly via a set of cmake probes into the following groups: - ECL_HAS_WIN_TIMERS - ECL_HAS_MACH_TIMERS - apple operating systems. - ECL_HAS_RT_TIMERS - ECL_HAS_POSIX_TIMERS - the fallback posix functions when -lrt is not available.
Include the following at the top of any translation unit which requires this library:
You will also need to link to -lecl_time_lite.
Use with the TimeError (an extension of ecl_errors' Error handler) that provides time function specific verbose error messages.
The function epoch_time is often not exactly epoch time (i.e. secs from 1970), but dependant on your platform. Nonetheless, it always provides a relative timer measuring in sec/nsecs. Note that the time is only guaranteed to be monotonic (i.e. it won't jump) if cmake has defined ECL_HAS_CLOCK_MONOTONIC.
The function cpu_time which is the amount of time that the process has actually spent executing on the cpu. This one is sometimes useful for benchmarking tests.
These don't really suit gtests, so a simple coverage example, ctest style, is provided. - src/examples/time_functions.cpp
- <b>Feb 11</b> : moved the portable api across from ecl_time and wrapped in the new error handlers.