Class MethodMeasurement
Used as a helper class to sample execution time of methods. Uses fluent pattern to build and needs to be executed with Run method.
Inherited Members
Namespace: Unity.PerformanceTesting.Measurements
Syntax
public class MethodMeasurement
Constructors
MethodMeasurement(Action)
Initializes a method measurement.
Declaration
public MethodMeasurement(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | Method to be measured. |
Methods
CleanUp(Action)
Used to provide a cleanup method which will not be measured.
Declaration
public MethodMeasurement CleanUp(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | Cleanup method to execute. |
Returns
Type | Description |
---|---|
MethodMeasurement |
DynamicMeasurementCount(Double, ConfidenceLevel, OutlierMode)
Dynamically find a suitable measurement count based on the margin of error of the samples. The measurements will stop once a certain amount of samples (specified by a confidence interval) falls within an acceptable error range from the result (defined by a relative error of the mean).
Declaration
public MethodMeasurement DynamicMeasurementCount(double maxRelativeError, ConfidenceLevel confidenceLevel = ConfidenceLevel.L99, OutlierMode outlierMode = OutlierMode.Remove)
Parameters
Type | Name | Description |
---|---|---|
Double | maxRelativeError | The maximum relative error of the mean that the margin of error must fall into. |
ConfidenceLevel | confidenceLevel | The confidence interval which will be used to calculate the margin of error. |
OutlierMode | outlierMode | Outlier mode allows to include or exclude outliers when evaluating the stop criterion. |
Returns
Type | Description |
---|---|
MethodMeasurement |
DynamicMeasurementCount(OutlierMode)
Dynamically find a suitable measurement count based on the margin of error of the samples. The measurements will stop once a certain amount of samples (specified by a confidence interval) falls within an acceptable error range from the result (defined by a relative error of the mean). A default margin of error range of 2% and a default confidence interval of 99% will be used.
Declaration
public MethodMeasurement DynamicMeasurementCount(OutlierMode outlierMode = OutlierMode.Remove)
Parameters
Type | Name | Description |
---|---|---|
OutlierMode | outlierMode | Outlier mode allows to include or exclude outliers when evaluating the stop criterion. |
Returns
Type | Description |
---|---|
MethodMeasurement |
GC()
Enables recording of garbage collector calls.
Declaration
public MethodMeasurement GC()
Returns
Type | Description |
---|---|
MethodMeasurement |
IterationsPerMeasurement(Int32)
Specifies the amount of method executions for a single measurement.
Declaration
public MethodMeasurement IterationsPerMeasurement(int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Count of method executions. |
Returns
Type | Description |
---|---|
MethodMeasurement |
MeasurementCount(Int32)
Specifies the number of measurements to take.
Declaration
public MethodMeasurement MeasurementCount(int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Count of measurements to take. |
Returns
Type | Description |
---|---|
MethodMeasurement |
ProfilerMarkers(String[])
Will record provided profiler markers once per frame.
Declaration
public MethodMeasurement ProfilerMarkers(params string[] profilerMarkerNames)
Parameters
Type | Name | Description |
---|---|---|
String[] | profilerMarkerNames | Profiler marker names as in profiler window. |
Returns
Type | Description |
---|---|
MethodMeasurement |
ProfilerMarkers(SampleGroup[])
Will record provided profiler markers once per frame with additional control over the SampleUnit.
Declaration
public MethodMeasurement ProfilerMarkers(params SampleGroup[] sampleGroups)
Parameters
Type | Name | Description |
---|---|---|
SampleGroup[] | sampleGroups | List of SampleGroups where a name matches the profiler marker and desired SampleUnit. |
Returns
Type | Description |
---|---|
MethodMeasurement |
Run()
Executes the measurement with given parameters. When MeasurementCount is not provided, a probing method will run to determine desired measurement counts.
Declaration
public void Run()
SampleGroup(String)
Overrides the default SampleGroup of "Time".
Declaration
public MethodMeasurement SampleGroup(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Desired name for measurement SampleGroup. |
Returns
Type | Description |
---|---|
MethodMeasurement |
SampleGroup(SampleGroup)
Overrides the default SampleGroup.
Declaration
public MethodMeasurement SampleGroup(SampleGroup sampleGroup)
Parameters
Type | Name | Description |
---|---|---|
SampleGroup | sampleGroup | SampleGroup with your desired name and unit. |
Returns
Type | Description |
---|---|
MethodMeasurement |
SetUp(Action)
Used to provide a setup method which will run before the measurement.
Declaration
public MethodMeasurement SetUp(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | Setup method to execute. |
Returns
Type | Description |
---|---|
MethodMeasurement |
WarmupCount(Int32)
Count of times to execute before measurements are collected. If unspecified, a default warmup will be assigned.
Declaration
public MethodMeasurement WarmupCount(int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Count of warmup iterations to execute. |
Returns
Type | Description |
---|---|
MethodMeasurement |