#include <TimeKeeper.h>
Public Types | |
typedef boost::posix_time::ptime | ptime |
typedef boost::posix_time::time_duration | deltat |
typedef std::pair< ptime, std::string > | event |
Public Member Functions | |
TimeKeeper (const std::string &msg="start", ptime starting_time=boost::posix_time::microsec_clock::local_time()) | |
~TimeKeeper () | |
ptime | start_time () const |
Return the time at which this time keeper was started. More... | |
ptime | last_time () const |
Return the time of the last event. More... | |
deltat | last_duration () const |
Return the duration between the last two events. More... | |
deltat | since (ptime now=boost::posix_time::microsec_clock::local_time()) const |
Return the time duration between "now" and the start time. More... | |
std::string | operator() (std::string msg="<tick>", ptime now=boost::posix_time::microsec_clock::local_time()) |
Record an event. More... | |
std::string | summary () const |
Return summary up to now. More... | |
event | operator[] (int ind) const |
Return event by index. More... | |
Private Member Functions | |
std::string | emit (int ind) const |
Emit a formatted message for the given event index. More... | |
Private Attributes | |
std::vector< event > | m_events |
A helper class to give some time keeping.
Use like
TimeKeeper tk("starting"); ... tk("starting long calculation...."); do_long_calculation(); tk("...done"); ... info(tk.summary());
Definition at line 21 of file TimeKeeper.h.
typedef boost::posix_time::time_duration WireCell::TimeKeeper::deltat |
Definition at line 24 of file TimeKeeper.h.
typedef std::pair<ptime, std::string> WireCell::TimeKeeper::event |
Definition at line 25 of file TimeKeeper.h.
typedef boost::posix_time::ptime WireCell::TimeKeeper::ptime |
Definition at line 23 of file TimeKeeper.h.
TimeKeeper::TimeKeeper | ( | const std::string & | msg = "start" , |
ptime | starting_time = boost::posix_time::microsec_clock::local_time() |
||
) |
Definition at line 8 of file TimeKeeper.cxx.
TimeKeeper::~TimeKeeper | ( | ) |
Definition at line 13 of file TimeKeeper.cxx.
|
private |
Emit a formatted message for the given event index.
Definition at line 57 of file TimeKeeper.cxx.
TimeKeeper::deltat TimeKeeper::last_duration | ( | ) | const |
Return the duration between the last two events.
Definition at line 31 of file TimeKeeper.cxx.
boost::posix_time::ptime TimeKeeper::last_time | ( | ) | const |
Return the time of the last event.
Definition at line 27 of file TimeKeeper.cxx.
std::string TimeKeeper::operator() | ( | std::string | msg = "<tick>" , |
ptime | now = boost::posix_time::microsec_clock::local_time() |
||
) |
Record an event.
Definition at line 17 of file TimeKeeper.cxx.
TimeKeeper::event TimeKeeper::operator[] | ( | int | ind | ) | const |
boost::posix_time::time_duration TimeKeeper::since | ( | ptime | now = boost::posix_time::microsec_clock::local_time() | ) | const |
Return the time duration between "now" and the start time.
Definition at line 36 of file TimeKeeper.cxx.
boost::posix_time::ptime TimeKeeper::start_time | ( | ) | const |
Return the time at which this time keeper was started.
Definition at line 23 of file TimeKeeper.cxx.
std::string TimeKeeper::summary | ( | ) | const |
Return summary up to now.
Definition at line 48 of file TimeKeeper.cxx.
|
private |
Definition at line 60 of file TimeKeeper.h.