cmTime.h : Added function cmTimeAbsElapsedMicros().

This commit is contained in:
kevin 2013-12-15 19:04:45 -05:00
parent e2a2295be6
commit 50677f8f0f
2 changed files with 19 additions and 8 deletions

View File

@ -59,3 +59,15 @@ unsigned cmTimeElapsedMicros( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 )
// take diff between t1 and t0
return u1 - u0;
}
unsigned cmTimeAbsElapsedMicros( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 )
{
if( t1->tv_sec > t0->tv_sec )
return cmTimeElapsedMicros(t0,t1);
if( t1->tv_sec == t0->tv_sec )
if( t1->tv_nsec > t0->tv_nsec )
return cmTimeElapsedMicros(t0,t1);
return cmTimeElapsedMicros(t1,t0);
}

View File

@ -24,15 +24,14 @@ extern "C" {
*/
void cmTimeGet( cmTimeSpec_t* t );
// Return the elapsed time (t1 - t0)
// in microseconds
unsigned cmTimeElapsedMicros
(
const
cmTimeSpec_t*
t0, //< ptr to start time
const cmTimeSpec_t* t1 );// ptr to end time
// 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 );
//)
//}