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

Used to measure performance of the currend thread. A standard unit operation is provided for which number of executions per second is measured. Beside number of unit operations per second, the ratio between the CPU time and the clock time is calculated, which gives the feeling of how much the processor on which the thread executes is loaded. Measurements can be performed by specifying the requested number of cycles, but also by specifying the requested time in seconds. More...

+ Collaboration diagram for IG.Lib.ThreadPerformanceTest:

Public Member Functions

 ThreadPerformanceTest ()
 
void TestPerformanceNum (int numCycles, out ThreadPerformanceData data)
 Execute performance test with specified number of standard cycles. WARNING: Usually the TestPerformance should be used which prescribes the approximate time used for the test. More...
 
void TestPerformanceNum (int numCycles, out double cyclesPerSec, out double performanceRatio)
 Execute performance test with specified number of standard cycles. WARNING: Usually the TestPerformance should be used which prescribes the approximate time used for the test. More...
 
double TestPerformanceNum (int numCycles)
 Execute performance test with specified number of standard cycles, and returns the measured number of standard cycles performed per second (which is the relevant performance measure). WARNING: Usually the TestPerformance should be used which prescribes the approximate time used for the test. More...
 
void TestPerformance (double testDuration, out ThreadPerformanceData data)
 Execute performance test with specified measurement duration. More...
 
void TestPerformance (double testDuration, out double cyclesPerSec, out double performanceRatio)
 Execute performance test with specified measurement duration. More...
 
double TestPerformance (double testDuration)
 Execute performance test with specified measurement duration, and returns the measured number of standard cycles performed per second (which is the relevant performance measure). More...
 
override string ToString ()
 

Static Public Member Functions

static void StandardCycle ()
 A standard unit operation that is repeated in order to measure performance. More...
 
static void CreateThreadLoads (int numThreads)
 Starts the specified number of new load threads, each of which causes a full load to a CPU core until it stops. IMPORTANT: The load threads are switched off by setting ThreadPerformanceTest.PerformLoad to false. It can happen that this must be repeated several times to take effect. More...
 
static void Example ()
 Examples and tests for this class. More...
 

Public Attributes

const int NumInner = 10000
 Number of inner iterations. This number is chosen such that there are over 1000 outer cycles per second on medium speed modern processors. More...
 
const double RefCyclesPerSecond = 1600
 A reference number of cycles per second. This can be used for orientation of how many cycles to request. More...
 
const int MinCycles = 20
 Minimial number of cycles. Test never executes with less cycles because of accuracy of results. More...
 
ThreadPerformanceData Last
 Performance data of the last measurement performed. More...
 

Protected Member Functions

void StoreLast ()
 Stores the last performance data. More...
 

Static Protected Member Functions

static void ThreadLoadFunction ()
 Performed by load threads. More...
 

Static Protected Attributes

static bool _performLoad = false
 
static int _numLoadThreads = 0
 

Properties

object Lock [get]
 
List< ThreadPerformanceDataData [get]
 List of data aboud the performed tests. More...
 
static int NumLoadThreds [get, protected set]
 Returns the current number of alive loading threads performing full CPU load. More...
 
static bool PerformLoad [get, set]
 Specifies whether load should be performed. Setting this to false makes eventual threads to exit. More...
 

Private Attributes

object _lock = new Object()
 
List< ThreadPerformanceData_data = new List<ThreadPerformanceData>()
 

Detailed Description

Used to measure performance of the currend thread. A standard unit operation is provided for which number of executions per second is measured. Beside number of unit operations per second, the ratio between the CPU time and the clock time is calculated, which gives the feeling of how much the processor on which the thread executes is loaded. Measurements can be performed by specifying the requested number of cycles, but also by specifying the requested time in seconds.

Constructor & Destructor Documentation

IG.Lib.ThreadPerformanceTest.ThreadPerformanceTest ( )
inline

Member Function Documentation

void IG.Lib.ThreadPerformanceTest.StoreLast ( )
inlineprotected

Stores the last performance data.

static void IG.Lib.ThreadPerformanceTest.StandardCycle ( )
inlinestatic

A standard unit operation that is repeated in order to measure performance.

void IG.Lib.ThreadPerformanceTest.TestPerformanceNum ( int  numCycles,
out ThreadPerformanceData  data 
)
inline

Execute performance test with specified number of standard cycles. WARNING: Usually the TestPerformance should be used which prescribes the approximate time used for the test.

Parameters
numCyclesNumber of standard cycles to be performed.
dataOutput structure that returns the performance data.

References IG.Lib.ThreadPerformanceData.CyclesPerSecond, IG.Lib.ThreadPerformanceData.NumCycles, IG.Lib.ThreadPerformanceData.NumIterations, IG.Lib.ThreadPerformanceData.PerformanceRatio, IG.Lib.StopWatch.Start(), IG.Lib.StopWatch.Stop(), IG.Lib.StopWatch.Time, IG.Lib.ThreadPerformanceData.Time, IG.Lib.StopWatch.TotalCpuTime, IG.Lib.StopWatch.TotalTime, and IG.Lib.ThreadPerformanceData.TotalTime.

Referenced by IG.Lib.ThreadPerformanceTest.Example().

void IG.Lib.ThreadPerformanceTest.TestPerformanceNum ( int  numCycles,
out double  cyclesPerSec,
out double  performanceRatio 
)
inline

Execute performance test with specified number of standard cycles. WARNING: Usually the TestPerformance should be used which prescribes the approximate time used for the test.

Parameters
numCyclesNumber of standard cycles to be performed performed.
cyclesPerSecReturns number of cycles per second, which is the relevant performance measure for the current thread.
performanceRatioReturns ratio between CPU time and clock time spen for the test. This is a measure of how much the CPU is loaded (smaller the value, more it is loaded).
double IG.Lib.ThreadPerformanceTest.TestPerformanceNum ( int  numCycles)
inline

Execute performance test with specified number of standard cycles, and returns the measured number of standard cycles performed per second (which is the relevant performance measure). WARNING: Usually the TestPerformance should be used which prescribes the approximate time used for the test.

Parameters
numCyclesNumber of standard cycles to be performed.
void IG.Lib.ThreadPerformanceTest.TestPerformance ( double  testDuration,
out ThreadPerformanceData  data 
)
inline
void IG.Lib.ThreadPerformanceTest.TestPerformance ( double  testDuration,
out double  cyclesPerSec,
out double  performanceRatio 
)
inline

Execute performance test with specified measurement duration.

Parameters
requestedTimeRequested (approximate) duration of the test.
cyclesPerSecReturns number of cycles per second, which is the relevant performance measure for the current thread.
performanceRatioReturns ratio between CPU time and clock time spen for the test. This is a measure of how much the CPU is loaded (smaller the value, more it is loaded).
double IG.Lib.ThreadPerformanceTest.TestPerformance ( double  testDuration)
inline

Execute performance test with specified measurement duration, and returns the measured number of standard cycles performed per second (which is the relevant performance measure).

Parameters
requestedTimeRequested (approximate) duration of the test.
static void IG.Lib.ThreadPerformanceTest.CreateThreadLoads ( int  numThreads)
inlinestatic

Starts the specified number of new load threads, each of which causes a full load to a CPU core until it stops. IMPORTANT: The load threads are switched off by setting ThreadPerformanceTest.PerformLoad to false. It can happen that this must be repeated several times to take effect.

Parameters
numThreads

Referenced by IG.Lib.ThreadPerformanceTest.Example().

static void IG.Lib.ThreadPerformanceTest.ThreadLoadFunction ( )
inlinestaticprotected

Performed by load threads.

override string IG.Lib.ThreadPerformanceTest.ToString ( )
inline

Member Data Documentation

const int IG.Lib.ThreadPerformanceTest.NumInner = 10000

Number of inner iterations. This number is chosen such that there are over 1000 outer cycles per second on medium speed modern processors.

const double IG.Lib.ThreadPerformanceTest.RefCyclesPerSecond = 1600

A reference number of cycles per second. This can be used for orientation of how many cycles to request.

const int IG.Lib.ThreadPerformanceTest.MinCycles = 20

Minimial number of cycles. Test never executes with less cycles because of accuracy of results.

object IG.Lib.ThreadPerformanceTest._lock = new Object()
private
ThreadPerformanceData IG.Lib.ThreadPerformanceTest.Last

Performance data of the last measurement performed.

List<ThreadPerformanceData> IG.Lib.ThreadPerformanceTest._data = new List<ThreadPerformanceData>()
private
bool IG.Lib.ThreadPerformanceTest._performLoad = false
staticprotected
int IG.Lib.ThreadPerformanceTest._numLoadThreads = 0
staticprotected

Property Documentation

object IG.Lib.ThreadPerformanceTest.Lock
getprotected
List<ThreadPerformanceData> IG.Lib.ThreadPerformanceTest.Data
get

List of data aboud the performed tests.

int IG.Lib.ThreadPerformanceTest.NumLoadThreds
staticgetprotected set

Returns the current number of alive loading threads performing full CPU load.

Referenced by IG.Lib.ThreadPerformanceTest.Example().

bool IG.Lib.ThreadPerformanceTest.PerformLoad
staticgetset

Specifies whether load should be performed. Setting this to false makes eventual threads to exit.

Referenced by IG.Lib.ThreadPerformanceTest.Example().


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