Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Chronometer.h

00001 #ifndef __VFN_CHRONOMETER__
00002 #define __VFN_CHRONOMETER__
00003 
00004 
00005 #include <stdlib.h>
00006 #include <ctime>
00007 #include <iostream.h>
00008 
00009 class Chronometer;
00010 class Chronometer
00011 {
00012    public:
00013       Chronometer(){this->start();};
00014       ~Chronometer(){};
00015       void start() {mPaused=false;time0=clock();};
00016       void pause() {time1=clock();mPaused=true;};
00017       void resume(){time0=clock()-(time1-time0);mPaused=false;};
00018       void print() 
00019       {
00020          if(mPaused == false) time1=clock();
00021          cout.setf(ios::fixed);
00022          int tmp=cout.precision(2);
00023          cout << "Elapsed time : " << (time1-time0)/(double)CLOCKS_PER_SEC << " s."<<endl ;
00024          cout.precision(tmp);
00025          cout.unsetf(ios::fixed);
00026       };
00027       double seconds()
00028       {
00029          if(mPaused ==false) time1=clock();
00030          return (time1-time0)/(double)CLOCKS_PER_SEC;
00031       };
00032    private:
00033       clock_t time0;
00034       clock_t time1;
00035       bool mPaused;
00036 };
00037 
00038 #endif

Generated on Wed Nov 14 19:48:35 2001 for ObjCryst++ by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001