7 #include <cgv/utils/stopwatch.h>
43 template<
typename T = std::
string>
47 std::map<T,double> counter_times;
48 std::map<T,int> counter_calls;
51 void prepare_counter(
const T &handle)
53 counter_times[handle]=0.0;
54 counter_calls[handle]=0;
58 inline double *get_time_accu(
const T handle)
60 counter_calls[handle]++;
61 return &(counter_times[handle]);
66 for(std::map<T,double>::iterator it = counter_times.begin();
67 it != counter_times.end();it++)
70 counter_calls[it->first]=0;
75 friend std::ostream& operator<< (std::ostream& out,
Profiler p)
77 for(std::map<T,double>::iterator it = p.counter_times.begin();
78 it != p.counter_times.end();it++)
80 out << it->first <<
": "<< p.counter_calls[it->first] <<
" calls, "<<it->second <<
" sec, "
81 << it->second/p.counter_calls[it->first] <<
" sec/call (mean)"<< std::endl;