blob: ac7514fb52c5371b86f2bc1ce2ee2869421e2ec5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#ifndef TIMESTAT_HH
#define TIMESTAT_HH
#include <iostream>
#include <list>
#include <string>
#include <cctk.h>
extern "C" {
#include "cycle.h"
}
namespace CarpetLib {
using namespace std;
class Timer;
// A set of timers
class TimerSet {
list <Timer *> timers;
public:
// Add a timer
void
add (Timer * timer);
// Remove a timer
void
remove (Timer * timer);
// Output all timer names
void
outputNames (ostream & os)
const;
// Output all timer data
void
outputData (ostream & os)
const;
}; // class TimerSet
inline
ostream & operator << (ostream & os,
TimerSet const & timerSet)
{
timerSet.outputData (os);
return os;
}
// A timer, which counts time (in seconds) spent in and amount (in
// bytes) used in various operations
class Timer {
string timername;
public:
// Create a new timer with the given name
Timer (char const * timername_);
// Destroy a timer
~Timer ();
private:
// Reset the statistics
void
resetstats ();
// Add statistics of a timing operation
void
addstat (double t,
double b);
private:
double wtime;
double wtime2;
double wmin;
double wmax;
double bytes;
double bytes2;
double bmin;
double bmax;
double count;
bool running;
ticks starttime;
public:
// Start the timer
void
start ();
// Stop the timer
void
stop (double b);
// Reset the timer
void
reset ();
// Timer name
string
name ()
const;
// Print timer data
void
outputData (ostream & os)
const;
};
inline
ostream & operator << (ostream & os,
Timer const & timer)
{
timer.outputData (os);
return os;
}
} // namespace CarpetLib
#endif // TIMESTAT_HH
|