Joutsen v0.5.0+12-g5dd5f7e
Public Member Functions | List of all members
Joutsen.Diagnostics.MethodTimer Class Reference

A timer that can be used to measure the execution time of a method. More...

Public Member Functions

TimerRun Run (Action methodToTime, int repetitions=0, int runAtLeastMs=200, Action setupMethod=null)
 Runs a performance test for the methodToTime by measuring the execution time. More...
 
RepeatedTimerRun RunRepeatedly (Action methodToTime, int runs=3, int repetitions=0, int runAtLeastMs=200, Action setupMethod=null)
 Runs a performance test for the methodToTime exactly runs times. More...
 

Detailed Description

A timer that can be used to measure the execution time of a method.

Remarks
The timer can run multiple repetitions and multiple entire test runs.
Since
0.3.0

Member Function Documentation

◆ Run()

TimerRun Joutsen.Diagnostics.MethodTimer.Run ( Action  methodToTime,
int  repetitions = 0,
int  runAtLeastMs = 200,
Action  setupMethod = null 
)

Runs a performance test for the methodToTime by measuring the execution time.

Parameters
methodToTimethe method to test. If it requires parameters it can be wrapped in a parameterless action
repetitionsthe number of repetitions for this test run. Default is zero (0). When set to zero the test run will use runAtLeastMs instead to determine the number of repetitions.
runAtLeastMsthe time in ms that should elapse before the test is stopped. The number of repetitions will be succeededly increased by powers of one until runAtLeastMs is exceeded.
setupMethoda method that is executed before each repetition. This can be used prepare or cleanup objects between repetitions.
Returns
the result of the test run

◆ RunRepeatedly()

RepeatedTimerRun Joutsen.Diagnostics.MethodTimer.RunRepeatedly ( Action  methodToTime,
int  runs = 3,
int  repetitions = 0,
int  runAtLeastMs = 200,
Action  setupMethod = null 
)

Runs a performance test for the methodToTime exactly runs times.

Parameters
methodToTimethe method to test. If it requires parameters it can be wrapped in a parameterless action.
runsthe number of times to repeat the entire test. Default is 3.
repetitionsthe number of repetitions for each test run. Default is zero (0). When set to zero the test run will use runAtLeastMs instead to determine the number of repetitions.
runAtLeastMsthe time in ms that should elapse before the one test is stopped. The number of repetitions will be succeededly increased by powers of one until runAtLeastMs is exceeded.
setupMethoda method that is executed before each repetition. This can be used prepare or cleanup objects between repetitions.
Returns
the result of the test runs