cwTime.h/cpp : Added elapsedSecs().

This commit is contained in:
kevin 2022-03-20 10:18:54 -04:00
parent 53dfdbc2a5
commit 1259ba96fb
2 changed files with 18 additions and 1 deletions

View File

@ -78,6 +78,19 @@ unsigned cw::time::elapsedMs( const spec_t& t0 )
return elapsedMs(t0,t1); return elapsedMs(t0,t1);
} }
double cw::time::elapsedSecs( const spec_t& t0, const spec_t& t1 )
{
return elapsedMicros(t0,t1) / 1000000.0;
}
double cw::time::elapsedSecs( const spec_t& t0 )
{
spec_t t1;
get(t1);
return elapsedSecs(t0,t1);
}
unsigned cw::time::absElapsedMicros( const spec_t& t0, const spec_t& t1 ) unsigned cw::time::absElapsedMicros( const spec_t& t0, const spec_t& t1 )
{ {
if( isLTE(t0,t1) ) if( isLTE(t0,t1) )

View File

@ -29,7 +29,11 @@ namespace cw
// Wrapper on elapsedMicros() // Wrapper on elapsedMicros()
unsigned elapsedMs( const spec_t& t0, const spec_t& t1 ); unsigned elapsedMs( const spec_t& t0, const spec_t& t1 );
unsigned elapsedMs( const spec_t& t0 ); unsigned elapsedMs( const spec_t& t0 );
// Wrapper on elapsedMicros()
double elapsedSecs( const spec_t& t0, const spec_t& t1 );
double elapsedSecs( const spec_t& t0 );
// Same as elapsedMicros() but the times are not assumed to be ordered. // Same as elapsedMicros() but the times are not assumed to be ordered.
// The function therefore begins by swapping t1 and t0 if t0 is after t1. // The function therefore begins by swapping t1 and t0 if t0 is after t1.
unsigned absElapsedMicros( const spec_t& t0, const spec_t& t1 ); unsigned absElapsedMicros( const spec_t& t0, const spec_t& t1 );