19#if __cplusplus >= 201103L || _MSC_VER >= 1600
21#elif defined(__linux__)
23#elif defined(_MSC_VER) || defined(__MINGW32__)
24# include <sys/timeb.h>
31# include <sys/resource.h>
39inline std::ostream& formatTime(std::ostream& os,
double sec)
46 double ss = (flo % 60) + sec;
47 if (hh > 0) os << hh <<
"h ";
48 if (mm > 0) os << mm <<
"m ";
49 std::streamsize prec = os.precision();
71template <
typename Clock>
80 void restart() { m_start = Clock::getTime(); }
83 double stop() {
return m_value = Clock::getTime() - m_start; }
86 double elapsed()
const {
return m_value; };
89 {
return formatTime(os, sw.m_value); }
91#if __cplusplus >= 201103L || _MSC_VER >= 1600
106#if __cplusplus >= 201103L || _MSC_VER >= 1600
110 static double getTime()
112 return ((std::chrono::duration<double>)std::chrono::high_resolution_clock::now().time_since_epoch()).count();
117typedef gsGenericStopwatch<CXX11WallClock>
gsStopwatch;
119#elif defined(__linux__)
124 static double getTime()
125 { timeval
tv; gettimeofday(&tv, 0);
return tv.tv_sec + 1e-6*
tv.tv_usec; }
129typedef gsGenericStopwatch<LinuxWallClock>
gsStopwatch;
131#elif defined(_MSC_VER) || defined(__MINGW32__)
133struct WindowsWallClock
135 static double getTime()
143 return (
double)tb.time + tb.millitm / 1000.0;
148typedef gsGenericStopwatch<WindowsWallClock>
gsStopwatch;
155 static double getTime()
156 { time_t secs; time (&secs);
return secs; }
169#if defined(__linux__)
176 static double getTime()
179 getrusage(RUSAGE_SELF, &ru);
180 return ru.ru_utime.tv_sec + 1.0e-6*ru.ru_utime.tv_usec;
194 static double getTime() {
return (
double) clock() / (double) CLOCKS_PER_SEC; }
A Stopwatch object can be used to measure execution time of code, algorithms, etc.
Definition gsStopwatch.h:73
double stop()
Return elapsed time in seconds.
Definition gsStopwatch.h:83
gsGenericStopwatch()
Declares a stop-watch.
Definition gsStopwatch.h:77
void restart()
Start taking the time.
Definition gsStopwatch.h:80
double elapsed() const
Returns the last recorded elapsed time.
Definition gsStopwatch.h:86
EIGEN_STRONG_INLINE tangent_expr< T > tv(const gsGeometryMap< T > &u)
The tangent boundary vector of a geometry map in 2D.
Definition gsExpressions.h:4513
The G+Smo namespace, containing all definitions for the library.
gsGenericStopwatch< WallClock > gsStopwatch
A stop-watch measuring real (wall) time.
Definition gsStopwatch.h:160
gsGenericStopwatch< CPUClock > gsCPUStopwatch
A stop-watch measuring CPU time.
Definition gsStopwatch.h:198