2 # ifndef CPPAD_UTILITY_ELAPSED_SECONDS_HPP
3 # define CPPAD_UTILITY_ELAPSED_SECONDS_HPP
85 # if CPPAD_USE_CPLUSPLUS_2011
88 extern double microsoft_timer(
void);
89 # elif CPPAD_HAS_GETTIMEOFDAY
90 # include <sys/time.h>
118 # if CPPAD_USE_CPLUSPLUS_2011
120 static bool first_ =
true;
121 static std::chrono::time_point<std::chrono::steady_clock> start_;
123 { start_ = std::chrono::steady_clock::now();
127 std::chrono::time_point<std::chrono::steady_clock> now;
128 now = std::chrono::steady_clock::now();
129 std::chrono::duration<double> difference = now - start_;
130 return difference.count();
134 {
return microsoft_timer(); }
136 # elif CPPAD_HAS_GETTIMEOFDAY
138 static bool first_ =
true;
139 static struct timeval tv_;
142 { gettimeofday(&tv_, CPPAD_NULL);
146 gettimeofday(&tv, CPPAD_NULL);
147 assert( tv.tv_sec >= tv_.tv_sec );
149 double sec = double(tv.tv_sec - tv_.tv_sec);
150 double usec = double(tv.tv_usec) - double(tv_.tv_usec);
151 double diff = sec + 1e-6*usec;
156 # else // Not CPPAD_USE_CPLUSPLUS_2011 or CPPAD_HAS_GETTIMEOFDAY
158 static bool first_ =
true;
162 { tic_ = double(std::clock());
166 tic = double( std::clock() );
168 double diff = (tic - tic_) /
double(CLOCKS_PER_SEC);
Define processor symbols and macros that are used by CppAD.
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
#define CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL
Check that the first call to a routine is not during parallel execution mode.
File used to define the CppAD multi-threading allocator class.
double elapsed_seconds(void)
Returns the elapsed number since the first call to this function.