ecl_time_lite Documentation

ecl_time_lite

Provides a portable set of time functions that are especially useful for porting other code or being wrapped by higher level c++ classes.

Embedded Control Library

    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.

Compiling & Linking

    Include the following at the top of any translation unit which
    requires this library:

    @code
    #include <ecl/time_lite.hpp>

    // The portable time functions.
    using ecl::time_lite::sleep;
    using ecl::time_lite::sleep_until;
    using ecl::time_lite::epoch_time;

    // Platform specific function (-lrt).
    using ecl::time_lite::cpu_time;
    @endcode

    You will also need to link to <i>-lecl_time_lite</i>.

Usage

    Use with the TimeError (an extension of ecl_errors' Error handler) that provides time function specific verbose error messages.

    @code
    ecl::TimeStructure duration;
    duration.tv_sec = 1;
    duration.tv_nsec = 300000000;
    ecl::TimeError error = ecl::sleep(duration);
    if ( error.flag() != ecl::NoError) {
            std::cout << error.what() << std::endl;
       // do something
    }
    @endcode

    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. 

Unit Tests

These don't really suit gtests, so a simple coverage example, ctest style, is provided.

    - src/examples/time_functions.cpp

ChangeLog

    - <b>Feb 11</b> : moved the portable api across from ecl_time and wrapped in the new error handlers.


ecl_time_lite
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:13:57