wall_clock_meat.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
00002 // Copyright (C) 2008-2010 Conrad Sanderson
00003 // 
00004 // This file is part of the Armadillo C++ library.
00005 // It is provided without any warranty of fitness
00006 // for any purpose. You can redistribute this file
00007 // and/or modify it under the terms of the GNU
00008 // Lesser General Public License (LGPL) as published
00009 // by the Free Software Foundation, either version 3
00010 // of the License or (at your option) any later version.
00011 // (see http://www.opensource.org/licenses for more info)
00012 
00013 
00016 
00017 
00018 inline
00019 wall_clock::wall_clock()
00020   : valid(false)
00021   {
00022   arma_extra_debug_sigprint();
00023   }
00024 
00025 
00026 
00027 inline
00028 wall_clock::~wall_clock()
00029   {
00030   arma_extra_debug_sigprint();
00031   }
00032 
00033 
00034 
00035 inline
00036 void
00037 wall_clock::tic()
00038   {
00039   arma_extra_debug_sigprint();
00040   
00041   #if defined(ARMA_USE_BOOST_DATE)
00042     {
00043     boost_time1 = boost::posix_time::microsec_clock::local_time();
00044     valid = true;
00045     }
00046   #else
00047     #if defined(ARMA_HAVE_GETTIMEOFDAY)
00048       {
00049       gettimeofday(&posix_time1, 0);
00050       valid = true;
00051       }
00052     #else
00053       {
00054       arma_stop("wall_clock::tic(): need Boost libraries or POSIX gettimeofday()");
00055       }
00056     #endif
00057   #endif
00058   }
00059 
00060 
00061 
00062 inline
00063 double
00064 wall_clock::toc()
00065   {
00066   arma_extra_debug_sigprint();
00067   
00068   if(valid)
00069     {
00070     #if defined(ARMA_USE_BOOST_DATE)
00071       {
00072       boost_duration = boost::posix_time::microsec_clock::local_time() - boost_time1;
00073       return boost_duration.total_microseconds() * 1e-6;
00074       }
00075     #else
00076       #if defined(ARMA_HAVE_GETTIMEOFDAY)
00077         {
00078         gettimeofday(&posix_time2, 0);
00079         
00080         const double tmp_time1 = posix_time1.tv_sec + posix_time1.tv_usec * 1.0e-6;
00081         const double tmp_time2 = posix_time2.tv_sec + posix_time2.tv_usec * 1.0e-6;
00082         
00083         return tmp_time2 - tmp_time1;
00084         }
00085       #else
00086         {
00087         arma_stop("wall_clock::toc(): need Boost libraries or POSIX gettimeofday()");
00088         return 0.0;
00089         }
00090       #endif
00091     #endif
00092     }
00093   else
00094     {  
00095     return 0.0;
00096     }
00097   }
00098 
00100 


armadillo_matrix
Author(s): Conrad Sanderson - NICTA (www.nicta.com.au), (Wrapper by Sjoerd van den Dries)
autogenerated on Tue Jan 7 2014 11:42:06