wall_clock_meat.hpp
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 inline
00021 wall_clock::wall_clock()
00022 : valid(false)
00023 {
00024 arma_extra_debug_sigprint();
00025 }
00026
00027
00028
00029 inline
00030 wall_clock::~wall_clock()
00031 {
00032 arma_extra_debug_sigprint();
00033 }
00034
00035
00036
00037 inline
00038 void
00039 wall_clock::tic()
00040 {
00041 arma_extra_debug_sigprint();
00042
00043 #if defined(ARMA_USE_BOOST_DATE)
00044 {
00045 boost_time1 = boost::posix_time::microsec_clock::local_time();
00046 valid = true;
00047 }
00048 #else
00049 #if defined(ARMA_HAVE_GETTIMEOFDAY)
00050 {
00051 gettimeofday(&posix_time1, 0);
00052 valid = true;
00053 }
00054 #else
00055 {
00056 arma_stop("wall_clock::tic(): need Boost libraries or POSIX gettimeofday()");
00057 }
00058 #endif
00059 #endif
00060 }
00061
00062
00063
00064 inline
00065 double
00066 wall_clock::toc()
00067 {
00068 arma_extra_debug_sigprint();
00069
00070 if(valid)
00071 {
00072 #if defined(ARMA_USE_BOOST_DATE)
00073 {
00074 boost_duration = boost::posix_time::microsec_clock::local_time() - boost_time1;
00075 return boost_duration.total_microseconds() * 1e-6;
00076 }
00077 #else
00078 #if defined(ARMA_HAVE_GETTIMEOFDAY)
00079 {
00080 gettimeofday(&posix_time2, 0);
00081
00082 const double tmp_time1 = posix_time1.tv_sec + posix_time1.tv_usec * 1.0e-6;
00083 const double tmp_time2 = posix_time2.tv_sec + posix_time2.tv_usec * 1.0e-6;
00084
00085 return tmp_time2 - tmp_time1;
00086 }
00087 #else
00088 {
00089 arma_stop("wall_clock::toc(): need Boost libraries or POSIX gettimeofday()");
00090 return 0.0;
00091 }
00092 #endif
00093 #endif
00094 }
00095 else
00096 {
00097 return 0.0;
00098 }
00099 }
00100
00101
00102