/usr/include/BALL/SYSTEM/timer.h is in libball1.4-dev 1.4.3~beta1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | // -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: timer.h,v 1.17 2005/07/29 12:38:15 amoll Exp $
//
#ifndef BALL_SYSTEM_TIMER_H
#define BALL_SYSTEM_TIMER_H
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
#ifdef BALL_HAS_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef BALL_HAS_TIME_H
# include <time.h>
#endif
#include <iostream>
namespace BALL
{
/** Timer Class
\ingroup System
*/
class BALL_EXPORT Timer
{
public:
/** @name Constructors and Destructors
*/
//@{
/** Default constructor.
Create a new timer. The timer is stopped.
*/
Timer();
/** Copy constructor.
Create a new timer from an existing timer.
*/
Timer(Timer& timer);
/** Destructor.
Destructs a timer object.
*/
virtual ~Timer();
//@}
/** Starting, Stopping and Resetting the timer
*/
//@{
/** Clear and stop the timer.
This sets the timer to zero and stops it when running.
@see reset
*/
void clear();
/** Start the timer.
The timer is started. If the timer is already running, <b>false</b>
is returned.
@return bool <b>false</b> if the timer was already running, <b>true</b> otherwise
*/
bool start();
/** Stop the timer.
The timer is stopped. If the timer was not running, <b>false</b>
is returned.
@return bool <b>false</b> if the was not running, <b>true</b> otherwise
*/
bool stop();
/** Clear the timer without stopping.
The timer is cleared, but not stopped (if running).
@see clear
*/
void reset();
//@}
/** @name Readout of the Timer
*/
//@{
/** Get clock time.
Return the accumulated clock (real) time in seconds.
*/
double getClockTime() const;
/** Get user time.
Return the accumulated user time in seconds.
*/
double getUserTime() const;
/** Get user time.
Return the accumulated system time in seconds.
*/
double getSystemTime() const;
/** Get CPU time.
Return the accumulated CPU time in seconds.
CPU time is the sum of user time and system time.
*/
double getCPUTime() const;
//@}
/** @name Assignment
*/
//@{
/** Assignment operator.
Assigns a timer from another. The two timer will then run
synchronously.
@return Timer <tt>*this</tt>
*/
Timer& operator = (const Timer& timer);
//@}
/** @name Predicates
*/
//@{
/** Return true if the timer is running.
@return bool <b>true</b> if the timer is running, <b>false</b> otherwise
*/
bool isRunning() const;
/** Equality operator.
Return <b>true</b> if two timers are equal, i.e. they contain exactly
the same time intervals for clock, user and system time and have the
same running status.
@param timer the timer to compare with
@return bool <b>true</b> on equality, <b>false</b> otherwise
*/
bool operator == (const Timer& timer) const;
/** Inequality operator.
Return <b>false</b> if two timers differ in any way, i.e. they differ
in either the clock, user, or system time or have a different
running status.
@param timer the timer to compare with
@return bool <b>true</b> on inequality, <b>false</b> otherwise
*/
bool operator != (const Timer& timer) const;
/** Lesser than operator.
Return true, if the timer is in all timings lesser than the
timer to be compared with (clock, user and system time).
@param timer the timer to compare with
@return bool <b>true</b> if all times are lesser
*/
bool operator < (const Timer& timer) const;
/** Lesser or equal operator.
Return true, if the timer is in all timings lesser or equal than the
timer to be compared with (clock, user and system time).
@param timer the timer to compare with
@return bool <b>true</b> if all times are lesser or equal
*/
bool operator <= (const Timer& timer) const;
/** Greater or equal operator.
Return true, if the timer is in all timings greater or equal than the
timer to be compared with (clock, user and system time).
@param timer the timer to compare with
@return bool <b>true</b> if all times are greater or equal
*/
bool operator >= (const Timer& timer) const;
/** Greater operator.
Return true, if the timer is in all timings greater than the
timer to be compared with (clock, user and system time).
@param timer the timer to compare with
@return bool <b>true</b> if all times are greater
*/
bool operator > (const Timer& timer) const;
//@}
/** @name Debugging and Diagnostics
*/
//@{
/** Test if the instance is valid.
Allways returns true.
*/
bool isValid() const;
/** Dump the timer's contents.
*/
void dump(::std::ostream& s = ::std::cout, Size depth = 0L) const;
//@}
protected:
private:
static LongSize cpu_speed_;
#ifdef BALL_HAS_WINDOWS_PERFORMANCE_COUNTER
static PointerSizeUInt clock_speed_;
#endif
// state of timer, either true(on) or false(off)
bool is_running_;
// clock seconds value when the timer was last started
LongSize last_secs_;
// clock useconds value when the timer was last started
LongSize last_usecs_;
// user time when the timer was last started
clock_t last_user_time_;
// system time when the timer was last started
clock_t last_system_time_;
// current accumulated clock seconds
LongSize current_secs_;
// current accumulated clock useconds
LongSize current_usecs_;
// current accumulated user time
clock_t current_user_time_;
// current accumulated user time
clock_t current_system_time_;
};
# ifndef BALL_NO_INLINE_FUNCTIONS
# include "timer.iC"
# endif
}
#endif // BALL_SYSTEM_TIMER_H
|