Permalink
Browse files

added operator to add timings

  • Loading branch information...
kosloot committed Feb 4, 2019
1 parent 433045c commit 210eba1b69248014c7edb110536ebe4f505b9730
Showing with 13 additions and 1 deletion.
  1. +2 −1 include/ticcutils/Timer.h
  2. +11 −0 src/Timer.cxx
@@ -40,7 +40,8 @@ namespace TiCC {
gettimeofday( &startTime, 0 );
};
void stop();
unsigned int secs() { stop(); return myTime.tv_sec; };
Timer& operator+=( const Timer& );
friend Timer operator+( Timer, const Timer& );
std::string toString();
static std::string now();
private:
@@ -60,6 +60,17 @@ namespace TiCC {
return os;
}

Timer& Timer::operator+=( const Timer& rhs ){
this->myTime.tv_sec += rhs.myTime.tv_sec;
this->myTime.tv_usec += rhs.myTime.tv_usec;
return *this;
}

Timer operator+( Timer lhs, const Timer& rhs){
lhs += rhs;
return lhs;
}

string Timer::toString(){
stringstream os;
os << *this;

0 comments on commit 210eba1

Please sign in to comment.