BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h
Go to the documentation of this file.
1// this is -*- c++ -*-
2// $Id: BesTimer.h,v 1.3 2011/02/18 04:23:58 maqm Exp $
3// $Name: BesTimerSvc-00-00-12 $
4#ifndef BesTIMER_H_
5#define BesTIMER_H_
6#include <sys/time.h>
7#include <iostream>
8#include <string>
9
10#include <complex>
11
12
13 class BesTimer {
14 public:
15 // constructor
16 BesTimer (const std::string name);
17
18 public:
19
20 // retrieve timer name
21 std::string& name() { return m_name; }
22 // retrieve elapsed time
23 float elapsed( void ) const { return (m_started? 0.0 : m_elapsed);}
24 // retrieve mean and rms time
25 double mean( void ) const { return m_mean;}
26 double rms( void ) const {
27 double var = m_ms - m_mean*m_mean;
28 return (var > 0 ? sqrt(var) : 0.0);
29 }
30 // retrieve number of measurements
31 int number_of_measurements( void ) const { return m_numberOfMeasurements;}
32
33 // set and retrieve property name
34 void propName(std::string name) { m_propName = name; }
35 std::string& propName() { return m_propName; }
36 // set and retrieve property value
37 inline unsigned int propVal() { return m_propVal;}
38 inline void propVal(unsigned int val) { m_propVal = val; }
39
40 double meanPropVal() { return m_meanVal;}
41 double meanTimePerObject() { return m_meanTimePerObject;}
42
43 // define less than operator based on name
44 bool operator < ( BesTimer &it) { return (this->name() < it.name());}
45
46 // methods to control clock
47 void start( void );
48 void stop ( void );
49 void pause ( void );
50 void resume( void );
51 void reset ();
52
53
54 private:
55 std::string m_name;
56 struct timeval m_startTime;
57 float m_elapsed;
58 double m_mean; // mean time
59 double m_ms; // mean squared time
60 int m_numberOfMeasurements;
61 bool m_started;
62 bool m_paused;
63 std::string m_propName;
64 unsigned int m_propVal;
65 double m_meanVal;
66 double m_meanTimePerObject;
67 int m_NmeanTimePerObject;
68
69 };
70
71#endif // BesTIMER_H
double m_mean
void pause(void)
void reset()
BesTimer(const std::string name)
void resume(void)
void start(void)
void stop(void)