cwTime.cpp/h : Added elapsedMs()

This commit is contained in:
kpl 2020-02-01 10:13:21 -05:00
parent 5927fcb43b
commit 3ef020648b
2 changed files with 6 additions and 0 deletions

View File

@ -61,6 +61,10 @@ unsigned cw::time::elapsedMicros( const spec_t* t0, const spec_t* t1 )
return u1 - u0; return u1 - u0;
} }
unsigned cw::time::elapsedMs( const spec_t* t0, const spec_t* t1 )
{ return elapsedMicros(t0,t1)/1000; }
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

@ -25,6 +25,8 @@ namespace cw
// t1 is assumed to be at a later time than t0. // t1 is assumed to be at a later time than t0.
unsigned elapsedMicros( const spec_t* t0, const spec_t* t1 ); unsigned elapsedMicros( const spec_t* t0, const spec_t* t1 );
// Wrapper on elapsedMicros()
unsigned elapsedMs( const spec_t* t0, const spec_t* t1 );
// 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.