Classes | Functions

Wall_clock

//! More...

Classes

class  wall_clock
 Class for measuring time intervals. More...

Functions

 wall_clock::wall_clock ()
 wall_clock::~wall_clock ()
void wall_clock::tic ()
 start the timer
double wall_clock::toc ()
 return the number of seconds since the last call to tic()

Detailed Description

//!


Function Documentation

wall_clock::wall_clock (  )  [inline, inherited]

Definition at line 22 of file wall_clock_meat.hpp.

  : valid(false)
  {
  arma_extra_debug_sigprint();
  }

wall_clock::~wall_clock (  )  [inline, inherited]

Definition at line 31 of file wall_clock_meat.hpp.

  {
  arma_extra_debug_sigprint();
  }

void wall_clock::tic (  )  [inline, inherited]

start the timer

Definition at line 40 of file wall_clock_meat.hpp.

References arma_stop(), boost_time1, posix_time1, and valid.

  {
  arma_extra_debug_sigprint();
  
  #if defined(ARMA_USE_BOOST_DATE)
    {
    boost_time1 = boost::posix_time::microsec_clock::local_time();
    valid = true;
    }
  #else
    #if defined(ARMA_HAVE_GETTIMEOFDAY)
      {
      gettimeofday(&posix_time1, 0);
      valid = true;
      }
    #else
      {
      arma_stop("wall_clock::tic(): need Boost libraries or POSIX gettimeofday()");
      }
    #endif
  #endif
  }

double wall_clock::toc (  )  [inline, inherited]

return the number of seconds since the last call to tic()

Definition at line 67 of file wall_clock_meat.hpp.

References arma_stop(), boost_duration, boost_time1, posix_time1, posix_time2, and valid.

  {
  arma_extra_debug_sigprint();
  
  if(valid)
    {
    #if defined(ARMA_USE_BOOST_DATE)
      {
      boost_duration = boost::posix_time::microsec_clock::local_time() - boost_time1;
      return boost_duration.total_microseconds() * 1e-6;
      }
    #else
      #if defined(ARMA_HAVE_GETTIMEOFDAY)
        {
        gettimeofday(&posix_time2, 0);
        
        const double tmp_time1 = posix_time1.tv_sec + posix_time1.tv_usec * 1.0e-6;
        const double tmp_time2 = posix_time2.tv_sec + posix_time2.tv_usec * 1.0e-6;
        
        return tmp_time2 - tmp_time1;
        }
      #else
        {
        arma_stop("wall_clock::toc(): need Boost libraries or POSIX gettimeofday()");
        return 0.0;
        }
      #endif
    #endif
    }
  else
    {  
    return 0.0;
    }
  }