38 #ifdef __CLOCK_GETTIME
54 Stopwatch::Time::operator double()
const{
55 return sec+0.000000001*nsec;
60 #ifdef __CLOCK_GETTIME
62 clock_gettime(CLOCK_REALTIME,&ts);
67 gettimeofday(&tv,NULL);
69 t.
nsec=1000*tv.tv_usec;
74 void Stopwatch::Time::reset(){
79 Stopwatch::Time::Time():
97 if(t.
nsec>1000000000){
106 cycles(0),running(false),paused(false) { }
109 plumed_assert(!running);
119 if(min>lap || cycles==1)min=lap;
125 plumed_assert(running);
145 for(
unsigned i=0;i<40;i++) os<<
" ";
146 os<<
" Cycles Total Average Minumum Maximum\n";
147 for(map<string,Watch>::const_iterator it=
watches.begin();it!=
watches.end();++it){
148 const Watch&t((*it).second);
149 std::string name((*it).first);
151 for(
unsigned i=name.length();i<40;i++) os<<
" ";
152 std::sprintf(buffer,
"%12u %12.6f %12.6f %12.6f %12.6f\n", t.
cycles,
double(t.
total),
double(t.
total/t.
cycles),
double(t.
min),
double(t.
max));
Time operator-(const Time &) const
Class to store a single stopwatch.
std::ostream & operator<<(std::ostream &os, const Stopwatch &sw)
Class to hold the value of absolute time.
unsigned nsec
I store nanosecond so as to allow high resolution clocks (even if likely time will be measured in mic...
std::ostream & log(std::ostream &) const
const Time & operator+=(const Time &)
Class implementing stopwatch to time execution.
std::map< std::string, Watch > watches