24 void StopWatch::calcDuration(
long& secs,
long& usecs){
30 if( startedP && stoppedP )
32 if( t_end.tv_sec < t_start.tv_sec )
34 QDPIO::cerr << __func__ <<
": critical timer rollover" << std::endl;
40 secs = t_end.tv_sec - t_start.tv_sec;
42 if( t_end.tv_usec < t_start.tv_usec )
47 usecs += t_end.tv_usec - t_start.tv_usec;
52 QDPIO::cerr << __func__ <<
": either stopwatch not started, or not stopped. I will return 0 instead!" << std::endl;
70 ret_val = gettimeofday(&t_start, NULL);
73 QDPIO::cerr << __func__ <<
": gettimeofday failed in StopWatch::start()" << std::endl;
87 QDPIO::cerr << __func__ <<
": attempting to stop a non running stopwatch in StopWatch::stop()" << std::endl;
91 ret_val = gettimeofday(&t_end, NULL);
94 QDPIO::cerr << __func__ <<
": gettimeofday failed in StopWatch::end()" << std::endl;
101 calcDuration(secs,usecs);
113 return static_cast<double>(usec)+
static_cast<double>(sec*1.e6);
118 return static_cast<double>(sec)+
static_cast<double>(usec)/1.e6;
double getTimeInSeconds()
Get time in seconds.
void reset()
Reset the timer.
double getTimeInMicroseconds()
Get time in microseconds.
void start()
Start the timer.
void stop()
Stop the timer.
StandardOutputStream cerr
Yet another random number generator.
Primary include file for QDP.