132 std::ostream& os = std::cout)
const;
138 friend std::ostream&
operator<< (std::ostream& os,
142 #ifndef DISABLE_TIMING
166 #ifndef DISABLE_TIMING
180 #ifndef DISABLE_TIMING
193 #ifndef DISABLE_TIMING
204 #ifndef DISABLE_TIMING
216 #ifndef DISABLE_TIMING
236 #ifndef DISABLE_TIMING
247 std::ostream& os)
const
249 #ifndef DISABLE_TIMING
255 case MICROSEC: os <<
" microsec.";
break;
256 case MILLISEC: os <<
" millisec.";
break;
257 case SECONDS: os <<
" sec.";
break;
258 case MINUTES: os <<
" min.";
break;
259 case HOURS: os <<
" h.";
break;
260 case DAYS: os <<
" days.";
break;
263 os <<
" (running: " << (
_running ?
"true" :
"false")
264 <<
", begin: " <<
_beg
282 gettimeofday (&now, (
struct timezone*)0);
size_t timeunit_t
Definition: stopwatch.h:67
void start()
Starts or resumes the stopwatch, if it is not running already.
Definition: stopwatch.h:164
timestamp_t _end
Definition: stopwatch.h:143
Definition: stopwatch.h:74
friend std::ostream & operator<<(std::ostream &os, const Stopwatch &stopwatch)
Convenient method for writing time in seconds to some ostream.
Definition: stopwatch.cpp:27
Definition: stopwatch.h:75
timestamp_t elapsed_timestamp() const
Returns the time elapsed between the start and stop of the stopwatch.
Definition: stopwatch.h:214
static bool correct_timeunit(timeunit_t t)
Definition: stopwatch.h:156
Definition: stopwatch.h:63
void reset()
Resets the stopwatch.
Definition: stopwatch.h:234
static timestamp_t get_timestamp()
Returns current time in microseconds since EPOCH.
Definition: stopwatch.h:275
void print(const char *msg="", timeunit_t timeunit=SECONDS, std::ostream &os=std::cout) const
This method prints out the currently elapsed time.
Definition: stopwatch.h:246
timestamp_t _beg
Definition: stopwatch.h:143
Definition: stopwatch.h:76
Definition: stopwatch.h:72
bool _running
Definition: stopwatch.h:145
Definition: stopwatch.h:73
Stopwatch()
Creates a stopwatch that is not running.
Definition: stopwatch.h:84
void stop()
Stops the stopwatch, if it is not stopped already.
Definition: stopwatch.h:178
size_t _prev_elapsed
Definition: stopwatch.h:144
bool isRunning() const
Returns, whether the stopwatch is running.
Definition: stopwatch.h:191
const double e
Definition: numerics.cpp:62
Definition: stopwatch.h:71
double elapsed(timeunit_t timeunit=SECONDS) const
Returns the time elapsed between the start and stop of the stopwatch.
Definition: stopwatch.h:202
size_t timestamp_t
Definition: stopwatch.h:66