IGLib
1.5
The IGLib base library for development of numerical, technical and business applications.
|
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...
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< ThreadPerformanceData > | Data [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>() |
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.
|
inline |
|
inlineprotected |
Stores the last performance data.
|
inlinestatic |
A standard unit operation that is repeated in order to measure performance.
|
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.
numCycles | Number of standard cycles to be performed. |
data | Output 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().
|
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.
numCycles | Number of standard cycles to be performed performed. |
cyclesPerSec | Returns number of cycles per second, which is the relevant performance measure for the current thread. |
performanceRatio | Returns 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). |
|
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.
numCycles | Number of standard cycles to be performed. |
|
inline |
Execute performance test with specified measurement duration.
requestedTime | Requested (approximate) duration of the test. |
data | Output 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().
|
inline |
Execute performance test with specified measurement duration.
requestedTime | Requested (approximate) duration of the test. |
cyclesPerSec | Returns number of cycles per second, which is the relevant performance measure for the current thread. |
performanceRatio | Returns 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). |
|
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).
requestedTime | Requested (approximate) duration of the test. |
|
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.
numThreads |
Referenced by IG.Lib.ThreadPerformanceTest.Example().
|
inlinestaticprotected |
Performed by load threads.
|
inline |
References IG.Lib.ThreadPerformanceData.ToString().
Referenced by IG.Lib.ThreadPerformanceTest.Example().
|
inlinestatic |
Examples and tests for this class.
References IG.Lib.ThreadPerformanceTest.CreateThreadLoads(), IG.Lib.ThreadPerformanceTest.NumLoadThreds, IG.Lib.ThreadPerformanceTest.PerformLoad, IG.Lib.ThreadPerformanceTest.TestPerformance(), IG.Lib.ThreadPerformanceTest.TestPerformanceNum(), and IG.Lib.ThreadPerformanceTest.ToString().
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.
|
private |
ThreadPerformanceData IG.Lib.ThreadPerformanceTest.Last |
Performance data of the last measurement performed.
|
private |
|
staticprotected |
|
staticprotected |
|
getprotected |
|
get |
List of data aboud the performed tests.
|
staticgetprotected set |
Returns the current number of alive loading threads performing full CPU load.
Referenced by IG.Lib.ThreadPerformanceTest.Example().
|
staticgetset |
Specifies whether load should be performed. Setting this to false makes eventual threads to exit.
Referenced by IG.Lib.ThreadPerformanceTest.Example().