IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.

IG::Lib::StopWatch Class Reference

Timer for measuring execution times and other intervals of time elapsed between successive events. $A Igor Apr10;. More...

Inheritance diagram for IG::Lib::StopWatch:
Collaboration diagram for IG::Lib::StopWatch:

List of all members.

Public Member Functions

 StopWatch ()
 StopWatch (string label)
double ThreadCpuTime ()
 Returns the total CPU time sent up to this moment by the current process.
void Start ()
 Starts the timer (the elapsed time & CPU time are measured since this moment). If the timer is already running then exception is thrown.
void Stop ()
 Stops the timer and adds the time and CPU time difference measured in the last round to the total time. If the timer is not running then exception is thrown.
void Reset ()
 Resets the timer. Its state becomes identical to the state right after creation (as it has not been used before).
void SetTimeStamp ()
 Sets the timestamp on the timer (marks the current time). This is done automatically by Reset(), Create() and constructors.
void SetLabel (string label)
override string ToString ()
string ToStringLong ()

Static Public Member Functions

static StopWatch Create ()
static StopWatch Create (string label)
static TimeSpan GetTimeSpan (double seconds)
 Gets a timespan object that is equivalent to the specified time in seconds, and returns it. There need not be whole number of seconds.
static void Example ()
 Example of using the stopwatch.

Static Public Attributes

static int MaxWarnCpu = 0

Protected Member Functions

void Init ()
void Init (string label)
void Warning (string warningstr)
 Prints out a warning related to timer use.

Protected Attributes

readonly object _lock = new object()
 Lock object to be used for locking the current object.
string _label = null
int _ID = 0
double _creationcCpuTime
DateTime _creationTime
double _totalTime
bool _running = false

Static Protected Attributes

static int lastId = 0
static int numWarnCpu = 0

Properties

static object StaticLock [get]
 Static lock object accessible only from the current class. Global lock object Util.LockGlobal is used to synchronize creation of this lock.
object Lock [get]
 Lock object to be used for locking the current object.
bool IsRunning [get]
 Returns a flag indicating whether the stopwatch is currently running.
int Id [get]
 Returns counter's ID.
DateTime TimeStamp [get]
 Gets the data from time stamp contained in the timer.
string Label [get]
double TotalTime [get]
 Gets the total time in seconds, measured by the timer up to the current moment. If the timer is running then the current absolute time is calculated, and difference with the last starting time added to the total time accumulated in previous rounds.
double TotalCpuTime [get]
 Gets the total CPU time in seconds, measured by the timer up to the current moment. If the timer is running then the current CPU time is calculated, and difference with the last starting CPU time added to the total CPU time accumulated in previous rounds.
double Time [get]
 Returns the elapsed time measured by the timer in the last round. If the timer is running then the current time is calculated and its difference with the starting time returned.
double CpuTime [get]
 Returns the elapsed CPU time measured by the timer in the last round. If the timer is running then the current CPU time is calculated and its difference with the starting time returned.
TimeSpan TimeSpan [get]
TimeSpan CpuTimeSpan [get]
TimeSpan TotalTimeSpan [get]
TimeSpan TotalCpuTimeSpan [get]

Private Attributes

double _totalCpuTime
double _startCpuTime
double _stopCpuTime
double _firstStartCpuTime
DateTime _startTime
DateTime _stopTime
DateTime _firstStartTime
bool _used = false
bool _measureTime = true
bool _measureCpuTime = true

Static Private Attributes

static object _staticLock

Detailed Description

Timer for measuring execution times and other intervals of time elapsed between successive events. $A Igor Apr10;.


Constructor & Destructor Documentation

IG::Lib::StopWatch::StopWatch ( ) [inline]
IG::Lib::StopWatch::StopWatch ( string  label) [inline]

Member Function Documentation

void IG::Lib::StopWatch::Init ( ) [inline, protected]
void IG::Lib::StopWatch::Init ( string  label) [inline, protected]
static StopWatch IG::Lib::StopWatch::Create ( ) [inline, static]
static StopWatch IG::Lib::StopWatch::Create ( string  label) [inline, static]
double IG::Lib::StopWatch::ThreadCpuTime ( ) [inline]

Returns the total CPU time sent up to this moment by the current process.

void IG::Lib::StopWatch::Warning ( string  warningstr) [inline, protected]

Prints out a warning related to timer use.

Parameters:
warningstr
void IG::Lib::StopWatch::Start ( ) [inline]

Starts the timer (the elapsed time & CPU time are measured since this moment). If the timer is already running then exception is thrown.

void IG::Lib::StopWatch::Stop ( ) [inline]

Stops the timer and adds the time and CPU time difference measured in the last round to the total time. If the timer is not running then exception is thrown.

void IG::Lib::StopWatch::Reset ( ) [inline]

Resets the timer. Its state becomes identical to the state right after creation (as it has not been used before).

void IG::Lib::StopWatch::SetTimeStamp ( ) [inline]

Sets the timestamp on the timer (marks the current time). This is done automatically by Reset(), Create() and constructors.

void IG::Lib::StopWatch::SetLabel ( string  label) [inline]
override string IG::Lib::StopWatch::ToString ( ) [inline]
string IG::Lib::StopWatch::ToStringLong ( ) [inline]
static TimeSpan IG::Lib::StopWatch::GetTimeSpan ( double  seconds) [inline, static]

Gets a timespan object that is equivalent to the specified time in seconds, and returns it. There need not be whole number of seconds.

Parameters:
secondsTime in seconds for which the equivalent TimeSpan object is returned.
static void IG::Lib::StopWatch::Example ( ) [inline, static]

Example of using the stopwatch.


Member Data Documentation

int IG::Lib::StopWatch::lastId = 0 [static, protected]
object IG::Lib::StopWatch::_staticLock [static, private]
readonly object IG::Lib::StopWatch::_lock = new object() [protected]

Lock object to be used for locking the current object.

string IG::Lib::StopWatch::_label = null [protected]
int IG::Lib::StopWatch::_ID = 0 [protected]
DateTime IG::Lib::StopWatch::_creationTime [protected]
DateTime IG::Lib::StopWatch::_startTime [private]
DateTime IG::Lib::StopWatch::_stopTime [private]
double IG::Lib::StopWatch::_totalTime [protected]
bool IG::Lib::StopWatch::_running = false [protected]
bool IG::Lib::StopWatch::_used = false [private]
bool IG::Lib::StopWatch::_measureTime = true [private]
bool IG::Lib::StopWatch::_measureCpuTime = true [private]
int IG::Lib::StopWatch::numWarnCpu = 0 [static, protected]

Property Documentation

object IG::Lib::StopWatch::StaticLock [static, get, protected]

Static lock object accessible only from the current class. Global lock object Util.LockGlobal is used to synchronize creation of this lock.

object IG::Lib::StopWatch::Lock [get]

Lock object to be used for locking the current object.

Implements IG::Lib::ILockable.

bool IG::Lib::StopWatch::IsRunning [get]

Returns a flag indicating whether the stopwatch is currently running.

int IG::Lib::StopWatch::Id [get]

Returns counter's ID.

Implements IG::Lib::IIdentifiable.

DateTime IG::Lib::StopWatch::TimeStamp [get]

Gets the data from time stamp contained in the timer.

string IG::Lib::StopWatch::Label [get]
double IG::Lib::StopWatch::TotalTime [get]

Gets the total time in seconds, measured by the timer up to the current moment. If the timer is running then the current absolute time is calculated, and difference with the last starting time added to the total time accumulated in previous rounds.

double IG::Lib::StopWatch::TotalCpuTime [get]

Gets the total CPU time in seconds, measured by the timer up to the current moment. If the timer is running then the current CPU time is calculated, and difference with the last starting CPU time added to the total CPU time accumulated in previous rounds.

double IG::Lib::StopWatch::Time [get]

Returns the elapsed time measured by the timer in the last round. If the timer is running then the current time is calculated and its difference with the starting time returned.

double IG::Lib::StopWatch::CpuTime [get]

Returns the elapsed CPU time measured by the timer in the last round. If the timer is running then the current CPU time is calculated and its difference with the starting time returned.

TimeSpan IG::Lib::StopWatch::TimeSpan [get]
TimeSpan IG::Lib::StopWatch::CpuTimeSpan [get]
TimeSpan IG::Lib::StopWatch::TotalTimeSpan [get]
TimeSpan IG::Lib::StopWatch::TotalCpuTimeSpan [get]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties Events