Package io.narayana.perf
Class PerformanceProfileStore
java.lang.Object
io.narayana.perf.PerformanceProfileStore
Maintain performance data and check for regressions.
Performance data and configuration is stored in a directory named by the system property
BASE_DIRECTORY_PROPERTY:
- PerformanceProfileStore.last holds the best performance run keyed by the name of the test
- PerformanceProfileStore.variance contains the variance for a test (keyed by test name) or, if not present, then the default variance
(eg 1.1 indicates a variance of lest than 10%)
- PerformanceProfileStore.args contains any arguments required by a test keyed by test name with value a comma separated string
(the configured values for arguments can be overridden by setting a system property called "testname.args" to the new value)
To disable regression checks set the boolean property FAIL_ON_PERF_REGRESSION_PROP
To reset performance data for a test set the boolean property RESET_NETRICS_PROP-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckPerformance(StringBuilder info, String metricName, float metricValue, boolean largerIsBetter) static booleancheckPerformance(String metricName, float metricValue) static booleancheckPerformance(String metricName, float metricValue, boolean largerIsBetter) static <T> TConvert a String to another typegetMatchingMetrics(String pattern) get metrics matching a particular patternstatic Floatstatic String[]getTestArgs(String metricName) Lookup any configured test argumentsPERFARGSFILENAMEstatic floatstatic floatgetVariance(String metricName) static booleanstatic booleanstatic <T> Measurement<T>regressionCheck(WorkerLifecycle lifecycle, WorkerWorkload<T> workload, String metricName, boolean useConfigArgs, long maxTestTime, int warmUpCount, int numberOfCalls, int threadCount, int batchSize) Measure the performance of a workload.static <T> Measurement<T>regressionCheck(WorkerWorkload<T> workload, String metricName, boolean useConfigArgs, int warmUpCount, int numberOfCalls, int threadCount, int batchSize) Measure the performance of a workload.static <T> Measurement<T>regressionCheck(WorkerWorkload<T> workload, String metricName, boolean useConfigArgs, long maxTestTime, int warmUpCount, int numberOfCalls, int threadCount, int batchSize) Measure the performance of a workload.
-
Field Details
-
BASE_DIRECTORY_PROPERTY
- See Also:
-
DEFAULT_VARIANCE
-
PERFDATAFILENAME
- See Also:
-
PERFVARIANCEFILENAME
- See Also:
-
PERFARGSFILENAME
- See Also:
-
PROPFILE_COMMENT
- See Also:
-
FAIL_ON_PERF_REGRESSION_PROP
- See Also:
-
RESET_NETRICS_PROP
- See Also:
-
resetMetrics
public static final boolean resetMetrics
-
-
Constructor Details
-
PerformanceProfileStore
public PerformanceProfileStore()
-
-
Method Details
-
isResetMetrics
public static boolean isResetMetrics() -
isFailOnRegression
public static boolean isFailOnRegression() -
getVariance
public static float getVariance() -
getVariance
-
getMetric
-
checkPerformance
-
checkPerformance
public static boolean checkPerformance(String metricName, float metricValue, boolean largerIsBetter) -
checkPerformance
public static boolean checkPerformance(StringBuilder info, String metricName, float metricValue, boolean largerIsBetter) -
regressionCheck
public static <T> Measurement<T> regressionCheck(WorkerWorkload<T> workload, String metricName, boolean useConfigArgs, int warmUpCount, int numberOfCalls, int threadCount, int batchSize) Measure the performance of a workload. The returnedMeasurementobject contains the results of the measurement.- Type Parameters:
T- caller specific context data- Parameters:
workload- the actual workload being measuredmetricName- the name of the test used as a key into performance dataPERFDATAFILENAMEuseConfigArgs- if true read test arguments from a file (getTestArgs(String)warmUpCount- Number of iterations of the workload to run before starting the measurementnumberOfCalls- Number of workload iterations (workload is called in batchSize batches until numberOfCalls is reached)threadCount- Number of threads used to complete the workloadbatchSize- The workload is responsible for running batchSize iterations on each call- Returns:
- the result of the measurement
-
regressionCheck
public static <T> Measurement<T> regressionCheck(WorkerWorkload<T> workload, String metricName, boolean useConfigArgs, long maxTestTime, int warmUpCount, int numberOfCalls, int threadCount, int batchSize) Measure the performance of a workload. The returnedMeasurementobject contains the results of the measurement.- Type Parameters:
T- caller specific context data- Parameters:
workload- the actual workload being measuredmetricName- the name of the test used as a key into performance dataPERFDATAFILENAMEuseConfigArgs- if true read test arguments from a file (getTestArgs(String)maxTestTime- Abort the measurement if this time (in msecs) is exceeded TODOwarmUpCount- Number of iterations of the workload to run before starting the measurementnumberOfCalls- Number of workload iterations (workload is called in batchSize batches until numberOfCalls is reached)threadCount- Number of threads used to complete the workloadbatchSize- The workload is responsible for running batchSize iterations on each call- Returns:
- the result of the measurement
-
regressionCheck
public static <T> Measurement<T> regressionCheck(WorkerLifecycle lifecycle, WorkerWorkload<T> workload, String metricName, boolean useConfigArgs, long maxTestTime, int warmUpCount, int numberOfCalls, int threadCount, int batchSize) Measure the performance of a workload. The returnedMeasurementobject contains the results of the measurement.- Type Parameters:
T- caller specific context data- Parameters:
lifecycle- lifecycle calls during the measurementworkload- the actual workload being measuredmetricName- the name of the test used as a key into performance dataPERFDATAFILENAMEuseConfigArgs- if true read test arguments from a file (getTestArgs(String)maxTestTime- Abort the measurement if this time (in msecs) is exceeded TODOwarmUpCount- Number of iterations of the workload to run before starting the measurementnumberOfCalls- Number of workload iterations (workload is called in batchSize batches until numberOfCalls is reached)threadCount- Number of threads used to complete the workloadbatchSize- The workload is responsible for running batchSize iterations on each call- Returns:
- the result of the measurement
-
getArg
public static <T> T getArg(String metricName, String[] args, int index, T defaultValue, Class<T> argClass) Convert a String to another type- Type Parameters:
T- the type which args[index] should be converted to- Parameters:
metricName- the name of the test to use if there was a data format errorargs- arguments returned from a prior call togetTestArgs(String)index- index into the args array to the value to be converteddefaultValue- default value if the index is out of rangeargClass- class type to convert the value to (which must have a constructor that takes a String value)- Returns:
- the converted value
-
getTestArgs
Lookup any configured test argumentsPERFARGSFILENAME- Parameters:
metricName- the name of the test- Returns:
- any test arguments or an empty array if there are none
-
getMatchingMetrics
get metrics matching a particular pattern- Parameters:
pattern- the regex used as the pattern- Returns:
- a map of matching metric names to the current value of the metric
-