IGLib  1.7.2
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.Lib.StopWatch1 Class Reference

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

+ Inheritance diagram for IG.Lib.StopWatch1:
+ Collaboration diagram for IG.Lib.StopWatch1:

Public Member Functions

 StopWatch1 ()
 
 StopWatch1 (string label)
 
double ThreadCpuTime ()
 Returns the total CPU time sent up to this moment by the current process. More...
 
void Start ()
 Starts the timer (the elapsed time and CPU time are measured since this moment). If the timer is already running then exception is thrown. More...
 
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. More...
 
void Reset ()
 Resets the timer. Its state becomes identical to the state right after creation (as it has not been used before). More...
 
void SetTimeStamp ()
 Sets the timestamp on the timer (marks the current time). This is done automatically by Reset(), Create() and constructors. More...
 
void SetLabel (string label)
 
override string ToString ()
 
string ToStringLong ()
 
delegate void VoidDelegate ()
 

Static Public Member Functions

static StopWatch1 Create ()
 
static StopWatch1 Create (string label)
 
static TimeSpan GetTimeSpan (double seconds)
 Gets a timespan object that is equivalent to the specified time in seconds, and returns it. More...
 
static void Example ()
 Example of using the stopwatch. More...
 
static int TestExecutionTime (VoidDelegate work, out double averageExecutionTime, out double averageCpuTime, double targetedTime=0.1, int outpuLevel=0, int numInitialExecutions=1)
 

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. More...
 

Protected Attributes

readonly object _lock = new object()
 Lock object to be used for locking the current object. More...
 
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. More...
 
object Lock [get]
 Lock object to be used for locking the current object. More...
 
bool IsRunning [get]
 Returns a flag indicating whether the stopwatch is currently running. More...
 
int Id [get]
 Returns counter's ID. More...
 
DateTime TimeStamp [get]
 Gets the data from time stamp contained in the timer. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
TimeSpan TimeSpan [get]
 
TimeSpan CpuTimeSpan [get]
 
TimeSpan TotalTimeSpan [get]
 
TimeSpan TotalCpuTimeSpan [get]
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 
- Properties inherited from IG.Lib.IIdentifiable
int Id [get]
 Returns unique ID (in the scope of a given type) of the current object. More...
 

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 xx Apr10 Jun15;

Constructor & Destructor Documentation

IG.Lib.StopWatch1.StopWatch1 ( )
inline
IG.Lib.StopWatch1.StopWatch1 ( string  label)
inline

Member Function Documentation

void IG.Lib.StopWatch1.Init ( )
inlineprotected
void IG.Lib.StopWatch1.Init ( string  label)
inlineprotected
static StopWatch1 IG.Lib.StopWatch1.Create ( )
inlinestatic
static StopWatch1 IG.Lib.StopWatch1.Create ( string  label)
inlinestatic
double IG.Lib.StopWatch1.ThreadCpuTime ( )
inline

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

void IG.Lib.StopWatch1.Warning ( string  warningstr)
inlineprotected

Prints out a warning related to timer use.

Parameters
warningstr
void IG.Lib.StopWatch1.Start ( )
inline

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

Referenced by IG.Lib.WaitFileEventLatenceBase.ExampleLatence.AlternateCreateRemoveExample(), IG.Crypto.CryptoManager.AppAsymTest(), IG.Crypto.CryptoManager.AppEncryptSymmetricAll(), IG.Num.SimKosecFileManagerBase.CalculateVectorResponse(), IG.Neural.NeuralAllpicationCommands.CmdTestJson(), IG.Neural.NeuralAllpicationCommands.cmdTestSerializationNeural(), IG.Script.ScriptAppBase.DataStructuresFunctionTestCsvReadDefinitionAndData(), IG.Script.ScriptAppBase.DataStructuresFunctionTestCsvWriteDefinitionAndData(), IG.Lib.StopWatch1.Example(), IG.Lib.RealFunctionLoader.Example(), IG.Lib.ScalarFunctionLoader.Example(), IG.Gr3d.TestVtkGraphicBase.ExampleCellsGridContours(), IG.Gr3d.TestVtkGraphicBase.ExampleCellsGridEfficient(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.ExampleClosestPointsDummy(), IG.Lib.UtilSystem.ExampleCopyDir(), IG.Gr3d.TestVtkGraphicBase.ExampleQuadCells(), IG.Gr3d.TestVtkGraphicBase.ExampleStructuredGrid(), IG.Lib.CommandLineApplicationInterpreter.ExitRepeatBlock(), IG.Script.LoadableScriptShellNeuralBase.ParSimRunJob(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.PrintNeighborDistanceStatistics(), IG.Lib.CommandLineApplicationInterpreter.RunRepeat(), IG.Script.LoadableScriptShellNeuralBase.TestAnalysis(), IG.Script.LoadableScriptShellNeuralBase.TestAnalysisTable(), IG.Script.LoadableScriptShellNeuralBase.TestApproximation(), IG.Script.LoadableScriptShellNeuralBase.TestApproximationTable(), IG.Num.MatrixBase.TestCholeskyDecomposition(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.TestClosestPoints(), IG.Script.LoadableScriptShellNeuralBase.TestClosestPoints(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.TestClosestPointsWithOutputs(), IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesLdlt_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesQR_IGLib(), IG.Lib.StopWatch1.TestExecutionTime(), IG.Num.VectorBase.TestGramSchmidtOrthogonalization(), IG.Num.MatrixBase.TestLdltDecomposition(), IG.Num.MatrixBase.TestLuDecomposition(), IG.Lib.ThreadPerformanceTest.TestPerformance(), IG.Num.ParallelJobContainerGen< InputType, ResultType >.TestPerformance(), IG.Lib.ThreadPerformanceTest.TestPerformanceNum(), IG.Lib.CharacterBuffer.TestSpeed(), IG.Num.ScalarFunctionUntransformedBase.TestSpeed(), and IG.Num.RealFunction.TestSpeed().

void IG.Lib.StopWatch1.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.

Referenced by IG.Lib.WaitFileEventLatenceBase.ExampleLatence.AlternateCreateRemoveExample(), IG.Crypto.CryptoManager.AppAsymTest(), IG.Crypto.CryptoManager.AppEncryptSymmetricAll(), IG.Num.SimKosecFileManagerBase.CalculateVectorResponse(), IG.Neural.NeuralAllpicationCommands.CmdTestJson(), IG.Neural.NeuralAllpicationCommands.cmdTestSerializationNeural(), IG.Script.ScriptAppBase.DataStructuresFunctionTestCsvReadDefinitionAndData(), IG.Script.ScriptAppBase.DataStructuresFunctionTestCsvWriteDefinitionAndData(), IG.Lib.StopWatch1.Example(), IG.Lib.RealFunctionLoader.Example(), IG.Lib.ScalarFunctionLoader.Example(), IG.Gr3d.TestVtkGraphicBase.ExampleCellsGridContours(), IG.Gr3d.TestVtkGraphicBase.ExampleCellsGridEfficient(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.ExampleClosestPointsDummy(), IG.Lib.UtilSystem.ExampleCopyDir(), IG.Gr3d.TestVtkGraphicBase.ExampleQuadCells(), IG.Gr3d.TestVtkGraphicBase.ExampleStructuredGrid(), IG.Lib.CommandLineApplicationInterpreter.ExitRepeatBlock(), IG.Script.LoadableScriptShellNeuralBase.ParSimRunJob(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.PrintNeighborDistanceStatistics(), IG.Lib.CommandLineApplicationInterpreter.RunRepeat(), IG.Script.LoadableScriptShellNeuralBase.TestAnalysis(), IG.Script.LoadableScriptShellNeuralBase.TestAnalysisTable(), IG.Script.LoadableScriptShellNeuralBase.TestApproximation(), IG.Script.LoadableScriptShellNeuralBase.TestApproximationTable(), IG.Num.MatrixBase.TestCholeskyDecomposition(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.TestClosestPoints(), IG.Script.LoadableScriptShellNeuralBase.TestClosestPoints(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.TestClosestPointsWithOutputs(), IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesLdlt_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesQR_IGLib(), IG.Num.VectorBase.TestGramSchmidtOrthogonalization(), IG.Num.MatrixBase.TestLdltDecomposition(), IG.Num.MatrixBase.TestLuDecomposition(), IG.Lib.ThreadPerformanceTest.TestPerformance(), IG.Lib.ThreadPerformanceTest.TestPerformanceNum(), IG.Lib.CharacterBuffer.TestSpeed(), and IG.Num.RealFunction.TestSpeed().

void IG.Lib.StopWatch1.SetTimeStamp ( )
inline

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

void IG.Lib.StopWatch1.SetLabel ( string  label)
inline
override string IG.Lib.StopWatch1.ToString ( )
inline
string IG.Lib.StopWatch1.ToStringLong ( )
inline
static TimeSpan IG.Lib.StopWatch1.GetTimeSpan ( double  seconds)
inlinestatic

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.
delegate void IG.Lib.StopWatch1.VoidDelegate ( )
static int IG.Lib.StopWatch1.TestExecutionTime ( VoidDelegate  work,
out double  averageExecutionTime,
out double  averageCpuTime,
double  targetedTime = 0.1,
int  outpuLevel = 0,
int  numInitialExecutions = 1 
)
inlinestatic

Member Data Documentation

int IG.Lib.StopWatch1.lastId = 0
staticprotected
object IG.Lib.StopWatch1._staticLock
staticprivate
readonly object IG.Lib.StopWatch1._lock = new object()
protected

Lock object to be used for locking the current object.

string IG.Lib.StopWatch1._label = null
protected
int IG.Lib.StopWatch1._ID = 0
protected
double IG.Lib.StopWatch1._creationcCpuTime
protected
double IG.Lib.StopWatch1._totalCpuTime
private
double IG.Lib.StopWatch1._startCpuTime
private
double IG.Lib.StopWatch1._stopCpuTime
private
double IG.Lib.StopWatch1._firstStartCpuTime
private
DateTime IG.Lib.StopWatch1._creationTime
protected
DateTime IG.Lib.StopWatch1._startTime
private
DateTime IG.Lib.StopWatch1._stopTime
private
DateTime IG.Lib.StopWatch1._firstStartTime
private
double IG.Lib.StopWatch1._totalTime
protected
bool IG.Lib.StopWatch1._running = false
protected
bool IG.Lib.StopWatch1._used = false
private
bool IG.Lib.StopWatch1._measureTime = true
private
bool IG.Lib.StopWatch1._measureCpuTime = true
private
int IG.Lib.StopWatch1.numWarnCpu = 0
staticprotected
int IG.Lib.StopWatch1.MaxWarnCpu = 0
static

Property Documentation

object IG.Lib.StopWatch1.StaticLock
staticgetprotected

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.StopWatch1.Lock
get

Lock object to be used for locking the current object.

bool IG.Lib.StopWatch1.IsRunning
get

Returns a flag indicating whether the stopwatch is currently running.

int IG.Lib.StopWatch1.Id
get

Returns counter's ID.

DateTime IG.Lib.StopWatch1.TimeStamp
get

Gets the data from time stamp contained in the timer.

string IG.Lib.StopWatch1.Label
get
double IG.Lib.StopWatch1.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.

Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll(), IG.Num.SimKosecFileManagerBase.CalculateVectorResponse(), IG.Neural.NeuralAllpicationCommands.CmdTestJson(), IG.Neural.NeuralAllpicationCommands.cmdTestSerializationNeural(), IG.Script.ScriptAppBase.DataStructuresFunctionTestCsvWriteDefinitionAndData(), IG.Lib.StopWatch1.Example(), IG.Gr3d.TestVtkGraphicBase.ExampleCellsGridContours(), IG.Gr3d.TestVtkGraphicBase.ExampleCellsGridEfficient(), IG.Gr3d.TestVtkGraphicBase.ExampleQuadCells(), IG.Gr3d.TestVtkGraphicBase.ExampleStructuredGrid(), IG.Lib.CommandLineApplicationInterpreter.ExitRepeatBlock(), IG.Lib.CommandLineApplicationInterpreter.RunRepeat(), IG.Num.MatrixBase.TestCholeskyDecomposition(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.TestClosestPoints(), IG.Script.LoadableScriptShellNeuralBase.TestClosestPoints(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.TestClosestPointsWithOutputs(), IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesLdlt_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesQR_IGLib(), IG.Num.MatrixBase.TestLdltDecomposition(), IG.Num.MatrixBase.TestLuDecomposition(), IG.Lib.ThreadPerformanceTest.TestPerformance(), IG.Lib.ThreadPerformanceTest.TestPerformanceNum(), and IG.Num.ScalarFunctionUntransformedBase.TestSpeed().

double IG.Lib.StopWatch1.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.

Referenced by IG.Lib.WaitFileEventLatenceBase.ExampleLatence.AlternateCreateRemoveExample(), IG.Crypto.CryptoManager.AppAsymTest(), IG.Crypto.CryptoManager.AppEncryptSymmetricAll(), IG.Num.SimKosecFileManagerBase.CalculateVectorResponse(), IG.Neural.NeuralAllpicationCommands.CmdTestJson(), IG.Neural.NeuralAllpicationCommands.cmdTestSerializationNeural(), IG.Script.ScriptAppBase.DataStructuresFunctionTestCsvReadDefinitionAndData(), IG.Lib.StopWatch1.Example(), IG.Lib.RealFunctionLoader.Example(), IG.Lib.ScalarFunctionLoader.Example(), IG.Gr3d.TestVtkGraphicBase.ExampleCellsGridContours(), IG.Gr3d.TestVtkGraphicBase.ExampleCellsGridEfficient(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.ExampleClosestPointsDummy(), IG.Lib.UtilSystem.ExampleCopyDir(), IG.Gr3d.TestVtkGraphicBase.ExampleQuadCells(), IG.Gr3d.TestVtkGraphicBase.ExampleStructuredGrid(), IG.Lib.CommandLineApplicationInterpreter.ExitRepeatBlock(), IG.Script.LoadableScriptShellNeuralBase.ParSimRunJob(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.PrintNeighborDistanceStatistics(), IG.Lib.CommandLineApplicationInterpreter.RunRepeat(), IG.Script.LoadableScriptShellNeuralBase.TestAnalysis(), IG.Script.LoadableScriptShellNeuralBase.TestAnalysisTable(), IG.Script.LoadableScriptShellNeuralBase.TestApproximation(), IG.Script.LoadableScriptShellNeuralBase.TestApproximationTable(), IG.Num.MatrixBase.TestCholeskyDecomposition(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.TestClosestPoints(), IG.Script.LoadableScriptShellNeuralBase.TestClosestPoints(), IG.Num.PointCloud< PointLinkType, PointContainerType, PointType >.TestClosestPointsWithOutputs(), IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesLdlt_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesQR_IGLib(), IG.Num.VectorBase.TestGramSchmidtOrthogonalization(), IG.Num.MatrixBase.TestLdltDecomposition(), IG.Num.MatrixBase.TestLuDecomposition(), IG.Lib.ThreadPerformanceTest.TestPerformance(), IG.Num.ParallelJobContainerGen< InputType, ResultType >.TestPerformance(), IG.Lib.ThreadPerformanceTest.TestPerformanceNum(), and IG.Lib.CharacterBuffer.TestSpeed().

TimeSpan IG.Lib.StopWatch1.TimeSpan
get
TimeSpan IG.Lib.StopWatch1.CpuTimeSpan
get
TimeSpan IG.Lib.StopWatch1.TotalTimeSpan
get
TimeSpan IG.Lib.StopWatch1.TotalCpuTimeSpan
get

The documentation for this class was generated from the following file: