0022904: Clean up sccsid variables
[occt.git] / src / OSD / OSD_PerfMeter.hxx
1 // File:      OSD_PerfMeter.hxx
2 // Created:   03.04.02 15:26:30
3 // Author:    Michael SAZONOV
4
5 #ifndef OSD_PerfMeter_HeaderFile
6 #define OSD_PerfMeter_HeaderFile
7
8 #include <OSD_PerfMeter.h>
9
10 //  This  class enables measuring  the CPU  time between  two points  of code
11 //  execution,  regardless of the scope of these points of code.   A meter is
12 //  identified by its name (string  of chars). So multiple objects in various
13 //  places of  user code may  point to the  same meter.  The results  will be
14 //  printed  on  stdout  upon  finish   of  the  program.   For  details  see
15 //  OSD_PerfMeter.h
16
17 class OSD_PerfMeter {
18
19  public:
20   // ---------- PUBLIC METHODS ----------
21
22   OSD_PerfMeter () : myIMeter(-1) {}
23   // constructs a void meter (to further call Init and Start)
24
25   OSD_PerfMeter (const char* meter, const unsigned autoStart = 1)
26     : myIMeter(perf_get_meter(meter,0,0)) {
27       if (myIMeter < 0) myIMeter = perf_init_meter(meter);
28       if (autoStart) Start();
29     }
30   // constructs and starts (if autoStart is true) the named meter
31
32   void Init (const char* meter) {
33     myIMeter = perf_get_meter(meter,0,0);
34     if (myIMeter < 0) myIMeter = perf_init_meter(meter);
35   }
36   // prepares the named meter
37
38   void Start    () const { perf_start_imeter(myIMeter); }
39   // starts the meter
40
41   void Stop     () const { perf_stop_imeter(myIMeter); }
42   // stops the meter
43
44   void Tick     () const { perf_tick_imeter(myIMeter); }
45   // increments the counter w/o time measurement
46
47   void Flush    () const { perf_close_imeter(myIMeter); }
48   // outputs the meter data and resets it to initial state
49
50   virtual ~OSD_PerfMeter () { if (myIMeter >= 0) Stop(); }
51   // assures stopping upon destruction
52
53  protected:
54   // ---------- PROTECTED FIELDS ----------
55
56   int myIMeter;
57 };
58
59 #endif