ecl_time_lite Documentation

ecl_time_lite: Cross platform api for low level time functions.

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

packageSummary

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:

CompilingLinking

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

        #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;

You will also need to link to -lecl_time_lite.

usage

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

        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
        }

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.

unitTests

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

ChangeLog



ecl_time_lite
Author(s): Daniel Stonier (d.stonier@gmail.com)
autogenerated on Thu Jan 2 2014 11:11:35