11 #if !defined(__MINGW32__) && !defined(__MINGW32_VERSION) 13 #include <sys/times.h> 27 double elapsed, user, system;
28 clock_t start_e, start_u, start_s;
30 Times(): counts(0), elapsed(0), user(0), system(0), started(
false) {}
36 inline std::map<std::string, Times>&
timers() {
37 static std::map<std::string, Times> _timers;
46 #pragma omp critical(ecolab_timers) 49 #if !defined(__MINGW32__) && !defined(__MINGW32_VERSION) 56 t.start_e = times(&tbuf);
57 t.start_u = tbuf.tms_utime;
58 t.start_s = tbuf.tms_stime;
68 #if !defined(__MINGW32__) && !defined(__MINGW32_VERSION) 75 t.start_e = times(&tbuf);
76 t.start_u = tbuf.tms_utime;
77 t.start_s = tbuf.tms_stime;
94 bool operator()(
const std::pair<std::string, Times>& x,
95 const std::pair<std::string, Times>& y)
97 return x.second.elapsed < y.second.elapsed;
102 inline void print_timers()
104 std::vector<std::pair<std::string, Times> > times
106 std::sort(times.begin(), times.end(),
SortElapsed());
109 std::cout <<
"------------------ Times --------------------------------\n";
110 for (
size_t i=0; i<times.size(); ++i)
111 std::cout <<
"Elapsed: "<<times[i].second.elapsed<<
112 " User: "<<times[i].second.user<<
" System: "<<times[i].second.system <<
113 " Counts: "<<times[i].second.counts<<
" "<<times[i].first<<std::endl;
114 std::cout <<
"----------------------------------------------------------"<<
void start_timer(const std::string &s)
Definition: timer.h:43
std::map< std::string, Times > & timers()
Definition: timer.h:36
RAII class for timing code blocks.
Definition: timer.h:84
void stop_timer(const std::string &s)
Definition: timer.h:66
_OPENMP
Definition: accessor.h:16