BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
Clock.h
Go to the documentation of this file.
1// $Id: Clock.h,v 1.1.1.1 2005/10/17 06:11:40 maqm Exp $
2//
3// Original Author: Sawyer Gillespie
5//
6
7#ifndef _H_CLOCK
8#define _H_CLOCK 1
9
10#if _MSC_VER >= 1000
11#pragma once
12#endif // _MSC_VER >= 1000
13
14// includes
15#include <cmath>
16
17// forward declarations
18typedef double ClockWord;
19
20// class Clock
21// This is a general class for representing a clock value in terms
22// of some integral number of counts (ie. CPU cycles).
23//
24class Clock
25{
26 public:
28 : m_time(0), m_freq(2.E7)
29 {}
30
31 virtual ClockWord count (double t)
32 {
33 m_time += t;
34 return m_time;
35 }
36
37 virtual ClockWord count (unsigned int c)
38 {
39 m_time += c * 1./m_freq;
40 return m_time;
41 }
42
43 virtual void reset ()
44 {
45 m_time = 0;
46 }
47
48 double freq () const
49 {
50 return m_freq;
51 }
52
53 virtual unsigned int cycles ()
54 {
55 return static_cast<unsigned>(ceil(m_time / m_freq));
56 }
57
58 virtual double elapsed ()
59 {
60 return m_time;
61 }
62
63 private:
64 ClockWord m_time; // current elapsed time in clock cycles
65 double m_freq; // frequency in Hz
66};
67
68#endif
double ClockWord
Definition Clock.h:18
TTree * t
Definition binning.cxx:23
Definition Clock.h:25
virtual double elapsed()
Definition Clock.h:58
virtual unsigned int cycles()
Definition Clock.h:53
virtual ClockWord count(unsigned int c)
Definition Clock.h:37
virtual void reset()
Definition Clock.h:43
virtual ClockWord count(double t)
Definition Clock.h:31
Clock()
Definition Clock.h:27
double freq() const
Definition Clock.h:48