wall_clock_meat.hpp
Go to the documentation of this file.
1 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2010 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12 
13 
16 
17 
18 inline
20  : valid(false)
21  {
23  }
24 
25 
26 
27 inline
29  {
31  }
32 
33 
34 
35 inline
36 void
38  {
40 
41  #if defined(ARMA_USE_BOOST_DATE)
42  {
43  boost_time1 = boost::posix_time::microsec_clock::local_time();
44  valid = true;
45  }
46  #else
47  #if defined(ARMA_HAVE_GETTIMEOFDAY)
48  {
49  gettimeofday(&posix_time1, 0);
50  valid = true;
51  }
52  #else
53  {
54  arma_stop("wall_clock::tic(): need Boost libraries or POSIX gettimeofday()");
55  }
56  #endif
57  #endif
58  }
59 
60 
61 
62 inline
63 double
65  {
67 
68  if(valid)
69  {
70  #if defined(ARMA_USE_BOOST_DATE)
71  {
72  boost_duration = boost::posix_time::microsec_clock::local_time() - boost_time1;
73  return boost_duration.total_microseconds() * 1e-6;
74  }
75  #else
76  #if defined(ARMA_HAVE_GETTIMEOFDAY)
77  {
78  gettimeofday(&posix_time2, 0);
79 
80  const double tmp_time1 = posix_time1.tv_sec + posix_time1.tv_usec * 1.0e-6;
81  const double tmp_time2 = posix_time2.tv_sec + posix_time2.tv_usec * 1.0e-6;
82 
83  return tmp_time2 - tmp_time1;
84  }
85  #else
86  {
87  arma_stop("wall_clock::toc(): need Boost libraries or POSIX gettimeofday()");
88  return 0.0;
89  }
90  #endif
91  #endif
92  }
93  else
94  {
95  return 0.0;
96  }
97  }
98 
100 
void arma_cold arma_stop(const T1 &x)
print a message to get_stream_err1() and/or throw a logic_error exception
Definition: debug.hpp:98
void tic()
start the timer
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
double toc()
return the number of seconds since the last call to tic()


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:59