org.eclipse.test.performance
Class Performance

java.lang.Object
  extended by org.eclipse.test.performance.Performance

public class Performance
extends java.lang.Object

Helper for performance measurements. Currently provides performance meter creation and checking of measurements. This class is not intended to be subclassed by clients.

Since:
3.1

Field Summary
static int EXPLAINS_DEGRADATION_COMMENT
          A comment kind of a comment that explains a performance degradation.
 
Method Summary
 void assertPerformance(PerformanceMeter performanceMeter)
          Asserts default properties of the measurements captured by the given performance meter.
 void assertPerformanceInAbsoluteBand(PerformanceMeter performanceMeter, Dimension dim, int lowerBand, int upperBand)
          Asserts that the measurement specified by the dimension captured in the given performance meter is within a certain range with respect to some reference value.
 void assertPerformanceInRelativeBand(PerformanceMeter performanceMeter, Dimension dim, int lowerPercentage, int upperPercentage)
          Asserts that the measurement specified by the dimension captured in the given performance meter is within a certain range with respect to some reference value.
 PerformanceMeter createPerformanceMeter(java.lang.String scenarioId)
          Creates a performance meter for the given scenario id.
static Performance getDefault()
          Returns the singleton of Performance
 java.lang.String getDefaultScenarioId(junit.framework.TestCase test)
          Returns a default scenario id for the given test.
 java.lang.String getDefaultScenarioId(junit.framework.TestCase test, java.lang.String id)
          Returns a default scenario id for the given test and id.
 PerformanceMeter getNullPerformanceMeter()
          Returns the null performance meter singleton.
 void setComment(PerformanceMeter pm, int commentKind, java.lang.String commentText)
          Set a comment for the scenario represented by the given PerformanceMeter.
 void tagAsGlobalSummary(PerformanceMeter pm, java.lang.String shortName, Dimension dimension)
          Mark the scenario represented by the given PerformanceMeter to be included into the global and the component performance summary.
 void tagAsGlobalSummary(PerformanceMeter pm, java.lang.String shortName, Dimension[] dimensions)
          Mark the scenario represented by the given PerformanceMeter to be included into the global and the component performance summary.
 void tagAsSummary(PerformanceMeter pm, java.lang.String shortName, Dimension dimension)
          Mark the scenario represented by the given PerformanceMeter to be included into the component performance summary.
 void tagAsSummary(PerformanceMeter pm, java.lang.String shortName, Dimension[] dimensions)
          Mark the scenario represented by the given PerformanceMeter to be included into the component performance summary.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPLAINS_DEGRADATION_COMMENT

public static final int EXPLAINS_DEGRADATION_COMMENT
A comment kind of a comment that explains a performance degradation.

See Also:
Constant Field Values
Method Detail

getDefault

public static Performance getDefault()
Returns the singleton of Performance

Returns:
the singleton of Performance

assertPerformance

public void assertPerformance(PerformanceMeter performanceMeter)
Asserts default properties of the measurements captured by the given performance meter.

Parameters:
performanceMeter - the performance meter
Throws:
java.lang.RuntimeException - if the properties do not hold

assertPerformanceInRelativeBand

public void assertPerformanceInRelativeBand(PerformanceMeter performanceMeter,
                                            Dimension dim,
                                            int lowerPercentage,
                                            int upperPercentage)
Asserts that the measurement specified by the dimension captured in the given performance meter is within a certain range with respect to some reference value. If the performance meter doesn't provide the specified dimension, the call has no effect.

Parameters:
performanceMeter - the performance meter
dim - the Dimension to check
lowerPercentage - a negative number indicating the percentage the measured value is allowed to be smaller than some reference value
upperPercentage - a positive number indicating the percentage the measured value is allowed to be greater than some reference value
Throws:
java.lang.RuntimeException - if the properties do not hold

assertPerformanceInAbsoluteBand

public void assertPerformanceInAbsoluteBand(PerformanceMeter performanceMeter,
                                            Dimension dim,
                                            int lowerBand,
                                            int upperBand)
Asserts that the measurement specified by the dimension captured in the given performance meter is within a certain range with respect to some reference value. If the performance meter doesn't provide the specified dimension, the call has no effect.

Parameters:
performanceMeter - the performance meter
dim - the Dimension to check
lowerBand - a negative number indicating the absolute amount the measured value is allowed to be smaller than some reference value
upperBand - a positive number indicating the absolute amount the measured value is allowed to be greater than some reference value
Throws:
java.lang.RuntimeException - if the properties do not hold

createPerformanceMeter

public PerformanceMeter createPerformanceMeter(java.lang.String scenarioId)
Creates a performance meter for the given scenario id.

Parameters:
scenarioId - the scenario id
Returns:
a performance meter for the given scenario id
Throws:
java.lang.IllegalArgumentException - if a performance meter for the given scenario id has already been created

getNullPerformanceMeter

public PerformanceMeter getNullPerformanceMeter()
Returns the null performance meter singleton.

Returns:
the null performance meter singleton

getDefaultScenarioId

public java.lang.String getDefaultScenarioId(junit.framework.TestCase test)
Returns a default scenario id for the given test. The test's name must have been set, such that test.getName() is not null.

Parameters:
test - the test
Returns:
the default scenario id for the test

getDefaultScenarioId

public java.lang.String getDefaultScenarioId(junit.framework.TestCase test,
                                             java.lang.String id)
Returns a default scenario id for the given test and id. The test's name must have been set, such that test.getName() is not null. The id distinguishes multiple scenarios in the same test.

Parameters:
test - the test
id - the id
Returns:
the default scenario id for the test and the id

tagAsGlobalSummary

public void tagAsGlobalSummary(PerformanceMeter pm,
                               java.lang.String shortName,
                               Dimension dimension)
Mark the scenario represented by the given PerformanceMeter to be included into the global and the component performance summary. The summary shows the given dimension of the scenario and labels the scenario with the short name.

Parameters:
pm - the PerformanceMeter
shortName - a short (shorter than 40 characters) descriptive name of the scenario
dimension - the dimension to show in the summary

tagAsGlobalSummary

public void tagAsGlobalSummary(PerformanceMeter pm,
                               java.lang.String shortName,
                               Dimension[] dimensions)
Mark the scenario represented by the given PerformanceMeter to be included into the global and the component performance summary. The summary shows the given dimensions of the scenario and labels the scenario with the short name.

Parameters:
pm - the PerformanceMeter
shortName - a short (shorter than 40 characters) descriptive name of the scenario
dimensions - an array of dimensions to show in the summary

tagAsSummary

public void tagAsSummary(PerformanceMeter pm,
                         java.lang.String shortName,
                         Dimension dimension)
Mark the scenario represented by the given PerformanceMeter to be included into the component performance summary. The summary shows the given dimension of the scenario and labels the scenario with the short name.

Parameters:
pm - the PerformanceMeter
shortName - a short (shorter than 40 characters) descriptive name of the scenario
dimension - the dimension to show in the summary

tagAsSummary

public void tagAsSummary(PerformanceMeter pm,
                         java.lang.String shortName,
                         Dimension[] dimensions)
Mark the scenario represented by the given PerformanceMeter to be included into the component performance summary. The summary shows the given dimensions of the scenario and labels the scenario with the short name.

Parameters:
pm - the PerformanceMeter
shortName - a short (shorter than 40 characters) descriptive name of the scenario
dimensions - an array of dimensions to show in the summary

setComment

public void setComment(PerformanceMeter pm,
                       int commentKind,
                       java.lang.String commentText)
Set a comment for the scenario represented by the given PerformanceMeter. Currently only comments with a commentKind of EXPLAINS_DEGRADATION_COMMENT are used. Their commentText is shown in a hover of the performance summaries graph if a performance degradation exists.

Parameters:
pm - the PerformanceMeter
commentKind - kind of comment. Must be EXPLAINS_DEGRADATION_COMMENT to have an effect.
commentText - the comment (shorter than 400 characters)