Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
// -*- 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
{
class BALL_EXPORT Timer
{
public:
/** Default constructor.
Create a new timer. The timer is stopped.
*/
Timer();
Create a new timer from an existing timer.
*/
Timer(Timer& timer);
*/
virtual ~Timer();
void clear();
bool start();
bool stop();
void reset();
double getClockTime() const;
double getUserTime() const;
double getSystemTime() const;
double getCPUTime() const;
Timer& operator = (const Timer& timer);
bool isRunning() const;
bool operator == (const Timer& timer) const;
bool operator != (const Timer& timer) const;
bool operator < (const Timer& timer) const;
bool operator <= (const Timer& timer) const;
bool operator >= (const Timer& timer) const;
bool operator > (const Timer& timer) const;
bool isValid() const;
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
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::Timer::stop
bool stop()
BALL::Timer::getUserTime
double getUserTime() const
BALL::Timer::Timer
Timer()
BALL::Timer::dump
void dump(::std::ostream &s=::std::cout, Size depth=0L) const
BALL::Timer::getClockTime
double getClockTime() const
BALL::Timer::clear
void clear()
BALL::Timer::~Timer
virtual ~Timer()
BALL::Timer::getSystemTime
double getSystemTime() const
BALL::Timer::isRunning
bool isRunning() const
Definition timer.h:14
BALL::Timer::start
bool start()
BALL::Timer::reset
void reset()
BALL::Timer::isValid
bool isValid() const
Definition timer.h:8
BALL::Timer::Timer
Timer(Timer &timer)
BALL::Timer::getCPUTime
double getCPUTime() const
Definition timer.h:20
common.h
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::PointerSizeUInt
BALL_POINTERSIZEUINT_TYPE PointerSizeUInt
Definition COMMON/global.h:207
BALL::LongSize
BALL_ULONG64_TYPE LongSize
Definition COMMON/global.h:192