Commit f7f7382d authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed bugs in tnlTimerRT

- the timer is now constructed as zero-initialized and stopped
- reset() clears the timer, but does not start it again
- getTime() no longer starts the timer if it is in a stopped state
parent 07d193cf
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -34,16 +34,9 @@ tnlTimerRT::tnlTimerRT()

void tnlTimerRT::reset()
{
#ifdef HAVE_TIME
   struct timeval tp;
   int rtn = gettimeofday( &tp, NULL );
   initial_time = ( double ) tp. tv_sec + 1.0e-6 * ( double ) tp. tv_usec;
   total_time = 0.0;
   stop_state = false;
#else
   initial_time = 0.0;
#endif

   total_time = 0.0;
   stop_state = true;
}

void tnlTimerRT::stop()
@@ -72,8 +65,10 @@ void tnlTimerRT::start()
double tnlTimerRT::getTime()
{
#ifdef HAVE_TIME
   if( ! stop_state ) {
      stop();
      start();
   }
   return total_time;
#endif
   return -1;