Skip to content

Commit

Permalink
added Timer::getRemainingTime() (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-c authored and awegrzyn committed Apr 9, 2019
1 parent b6ef277 commit b16d239
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/Common/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class Timer {

/// \return Returns time elapsed since reset, in microseconds.
double getTime();

/// \return Returns the time until next timeout, in microseconds. This may be a negative value if timeout occured already.
double getRemainingTime();

private:
std::chrono::time_point<std::chrono::high_resolution_clock> t0; // time of reset
Expand Down
5 changes: 5 additions & 0 deletions src/Timer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,10 @@ double Timer::getTime() {
return tdiff.count();
}

double Timer::getRemainingTime() {
std::chrono::duration<double> tdiff= std::chrono::high_resolution_clock::now() - t0;
return tmax-tdiff.count();
}

} // namespace Common
} // namespace AliceO2

0 comments on commit b16d239

Please sign in to comment.