X-Git-Url: http://sjero.net/git/?p=iperf;a=blobdiff_plain;f=include%2FTimestamp.hpp;h=d98bcfcd13254b3ba13273183e41efbe5ae9a98e;hp=ae05f859a1cadaf4c51a82898873625831a9f314;hb=fad82d47d76abc8f4ac6767e58b89859ad35a2ca;hpb=0b373e070771aa2bc368ec82dbd4f48e69f5faf9 diff --git a/include/Timestamp.hpp b/include/Timestamp.hpp index ae05f85..d98bcfc 100644 --- a/include/Timestamp.hpp +++ b/include/Timestamp.hpp @@ -151,6 +151,16 @@ public: (mTime.tv_usec - right.tv_usec); } + /* ------------------------------------------------------------------- + * Return the number of microseconds from now to last time of setting. + * ------------------------------------------------------------------- */ + long delta_usec(void) { + struct timeval previous = mTime; + + setnow(); + return subUsec(previous); + } + /* ------------------------------------------------------------------- * subtract the right timestamp from my timestamp. * return the difference in seconds as a floating point. @@ -199,15 +209,6 @@ public: mTime.tv_usec < kMillion ); } - /* ------------------------------------------------------------------- - * return true if my timestamp is before the right timestamp. - * ------------------------------------------------------------------- */ - bool before( Timestamp right ) { - return mTime.tv_sec < right.mTime.tv_sec || - (mTime.tv_sec == right.mTime.tv_sec && - mTime.tv_usec < right.mTime.tv_usec); - } - /* ------------------------------------------------------------------- * return true if my timestamp is before the right timestamp. * ------------------------------------------------------------------- */ @@ -216,15 +217,17 @@ public: (mTime.tv_sec == right.tv_sec && mTime.tv_usec < right.tv_usec); } + bool before( Timestamp right ) { return before(right.mTime); } /* ------------------------------------------------------------------- * return true if my timestamp is after the right timestamp. * ------------------------------------------------------------------- */ - bool after( Timestamp right ) { - return mTime.tv_sec > right.mTime.tv_sec || - (mTime.tv_sec == right.mTime.tv_sec && - mTime.tv_usec > right.mTime.tv_usec); + bool after( timeval right ) { + return mTime.tv_sec > right.tv_sec || + (mTime.tv_sec == right.tv_sec && + mTime.tv_usec > right.tv_usec); } + bool after( Timestamp right ) { return after(right.mTime); } /** * This function returns the fraction of time elapsed after the beginning