Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:19:44

0001 #ifndef Stopwatch_header
0002 #define Stopwatch_header
0003 
0004 #include <ctime>
0005 
0006 class Stopwatch
0007 {
0008   private:
0009     time_t start, end;
0010   public:
0011     Stopwatch() {start=clock(); end=0;}
0012     void tic() {start=clock();}
0013     void toc() {end=clock();}
0014     double takeTime() {return ((double)(end - start)) / CLOCKS_PER_SEC;}
0015 };
0016 
0017 #endif
0018 
0019 /*-----------------------------------------------------------------------
0020   Usage:
0021   Declare a class as:
0022     Stopwatch sw;
0023   Then the time a piece of code takes can be recorded as:
0024     sw.tic();
0025     **** code ****
0026     sw.toc();
0027   And the result can be outputted using:
0028     cout << sw.takeTime() << endl;
0029 -----------------------------------------------------------------------*/