Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 inline
00022 wall_clock::wall_clock()
00023 : valid(false)
00024 {
00025 arma_extra_debug_sigprint();
00026 }
00027
00028
00029
00030 inline
00031 wall_clock::~wall_clock()
00032 {
00033 arma_extra_debug_sigprint();
00034 }
00035
00036
00037
00038 inline
00039 void
00040 wall_clock::tic()
00041 {
00042 arma_extra_debug_sigprint();
00043
00044 #if defined(ARMA_USE_BOOST_DATE)
00045 {
00046 boost_time1 = boost::posix_time::microsec_clock::local_time();
00047 valid = true;
00048 }
00049 #else
00050 #if defined(ARMA_HAVE_GETTIMEOFDAY)
00051 {
00052 gettimeofday(&posix_time1, 0);
00053 valid = true;
00054 }
00055 #else
00056 {
00057 arma_stop("wall_clock::tic(): need Boost libraries or POSIX gettimeofday()");
00058 }
00059 #endif
00060 #endif
00061 }
00062
00063
00064
00065 inline
00066 double
00067 wall_clock::toc()
00068 {
00069 arma_extra_debug_sigprint();
00070
00071 if(valid)
00072 {
00073 #if defined(ARMA_USE_BOOST_DATE)
00074 {
00075 boost_duration = boost::posix_time::microsec_clock::local_time() - boost_time1;
00076 return boost_duration.total_microseconds() * 1e-6;
00077 }
00078 #else
00079 #if defined(ARMA_HAVE_GETTIMEOFDAY)
00080 {
00081 gettimeofday(&posix_time2, 0);
00082
00083 const double tmp_time1 = posix_time1.tv_sec + posix_time1.tv_usec * 1.0e-6;
00084 const double tmp_time2 = posix_time2.tv_sec + posix_time2.tv_usec * 1.0e-6;
00085
00086 return tmp_time2 - tmp_time1;
00087 }
00088 #else
00089 {
00090 arma_stop("wall_clock::toc(): need Boost libraries or POSIX gettimeofday()");
00091 return 0.0;
00092 }
00093 #endif
00094 #endif
00095 }
00096 else
00097 {
00098 return 0.0;
00099 }
00100 }
00101
00102
00103