BOSS
6.6.4.p03
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
4
//
[email protected]
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
18
typedef
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
//
24
class
Clock
25
{
26
public
:
27
Clock
()
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
ClockWord
double ClockWord
Definition:
Clock.h:18
Clock
Definition:
Clock.h:25
Clock::elapsed
virtual double elapsed()
Definition:
Clock.h:58
Clock::cycles
virtual unsigned int cycles()
Definition:
Clock.h:53
Clock::count
virtual ClockWord count(unsigned int c)
Definition:
Clock.h:37
Clock::reset
virtual void reset()
Definition:
Clock.h:43
Clock::count
virtual ClockWord count(double t)
Definition:
Clock.h:31
Clock::Clock
Clock()
Definition:
Clock.h:27
Clock::freq
double freq() const
Definition:
Clock.h:48
t
int t()
Definition:
t.c:1
source
Calibration
facilities
facilities-00-00-03
facilities
Clock.h
Generated by
1.9.6