Page MenuHomec4science

surface_timer.hh
No OneTemporary

File Metadata

Created
Sun, Jun 30, 20:55

surface_timer.hh

/* -------------------------------------------------------------------------- */
#if defined(TIMER) && defined(USING_TIMER)
/* -------------------------------------------------------------------------- */
#include <map>
#include <time.h>
#include <fstream>
/* -------------------------------------------------------------------------- */
extern std::map<std::string,struct timespec> mesT;
extern std::map<std::string,UInt> nmes;
extern std::map<std::string,struct timespec> tstart;
extern std::map<std::string,struct timespec> tstop;
/* -------------------------------------------------------------------------- */
#define SEC_IN_NANOSEC 1000000000
/* -------------------------------------------------------------------------- */
#define STARTTIMER(x) { \
if (!mesT.count(x)) { \
mesT[x].tv_sec = 0; \
mesT[x].tv_nsec = 0; \
} \
clock_gettime(CLOCK_REALTIME,&(tstart[x])); \
}
/* -------------------------------------------------------------------------- */
#define STOPTIMER(x) { \
clock_gettime(CLOCK_REALTIME,&(tstop[x])); \
mesT[x].tv_sec += (tstop[x].tv_sec - tstart[x].tv_sec); \
mesT[x].tv_nsec += (tstop[x].tv_nsec - tstart[x].tv_nsec); \
if (mesT[x].tv_nsec < 0) { \
--mesT[x].tv_sec; \
mesT[x].tv_nsec += SEC_IN_NANOSEC; \
} \
if (mesT[x].tv_nsec >= SEC_IN_NANOSEC){ \
++mesT[x].tv_sec; \
mesT[x].tv_nsec -= SEC_IN_NANOSEC; \
} \
++nmes[x]; \
}
/* -------------------------------------------------------------------------- */
#else
#define STARTTIMER(x)
#define STOPTIMER(x)
#endif
void dumpTimes(UInt proc_number = 0);

Event Timeline