Copyright (C) Kevin Larke 2009-2020

This file is part of libcm.

libcm is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

libcm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See the GNU General Public License distributed with the libcm package or look here: .


cmTime : Time cand clock related functions.

This interface is used to read the systems high resolution timer and calculate elapsed time.


typedef  struct timespec cmTimeSpec_t;

// Get the time 
void cmTimeGet( cmTimeSpec_t* t );

// Return the elapsed time (t1 - t0) in microseconds
// t1 is assumed to be at a later time than t0.
unsigned cmTimeElapsedMicros( const cmTimeSpec_t*  t0, const cmTimeSpec_t* t1 );


// Same as cmTimeElapsedMicros() but the times are not assumed to be ordered.
// The function therefore begins by swapping t1 and t0 if t0 is after t1.
unsigned cmTimeAbsElapsedMicros( const cmTimeSpec_t*  t0, const cmTimeSpec_t* t1 ); 


// Same as cmTimeElapsedMicros() but returns a negative value if t0 is after t1.
int cmTimeDiffMicros( const cmTimeSpec_t*  t0, const cmTimeSpec_t* t1 );


// Returns true if t0 &lt=  t1.
bool cmTimeIsLTE( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 );

// Return true if t0 &gt= t1.
bool cmTimeIsGTE( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 );

bool cmTimeIsEqual( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 );

bool cmTimeIsZero( const cmTimeSpec_t* t0 );

void cmTimeSetZero( cmTimeSpec_t* t0 );