public class Performetrics extends Object
| Modifier and Type | Method and Description |
|---|---|
static MonitoredOperation |
monitorOperation(Runnable runnable)
Runs the specified
Runnable, which can also be a lambda expression, and
collects metrics for all available counter types. |
static MonitoredOperation |
monitorOperation(Runnable runnable,
Counter.Type... types)
Runs the specified
Runnable, which can also be a lambda expression, and
collects metrics for the specified counter type(s) only. |
static void |
setDefaultConversionMode(ConversionMode conversionMode)
Sets a conversion mode to be applied by supported operations if no specific mode is
set.
|
static void |
setDefaultPrintStyle(PrintStyle printStyle)
Defines the default
PrintStyle to be applied when no style is specified. |
static void |
setDefaultPrintStyleForDetails(PrintStyle printStyle)
Defines the default
PrintStyle to be applied by the detailed stopwatch
formatter. |
static void |
setDefaultPrintStyleForSummary(PrintStyle printStyle)
Defines the default
PrintStyle to be applied by the summarized stopwatch
formatter. |
static void |
setDefaultTimeUnit(TimeUnit timeUnit)
Sets a time unit to be maintained by default if no specific time unit is specified.
|
static void |
setScale(int scale)
Sets a maximum number of decimal places to be applied if double-precision conversion
mode is set.
|
public static void setDefaultTimeUnit(TimeUnit timeUnit)
timeUnit - the TimeUnit to setpublic static void setDefaultConversionMode(ConversionMode conversionMode)
conversionMode - the ConversionMode to setpublic static void setScale(int scale)
scale - a number between 0 and 16 to be setIllegalArgumentException - if a number outside the allowed range is receivedpublic static void setDefaultPrintStyle(PrintStyle printStyle)
PrintStyle to be applied when no style is specified.
The object will be used by the following operations:
printStyle - the PrintStyle to be set; not nullNullPointerException - if the specified PrintStyle is nullpublic static void setDefaultPrintStyleForSummary(PrintStyle printStyle)
PrintStyle to be applied by the summarized stopwatch
formatter.
The object will be used by the following operations:
printStyle - the PrintStyle to be set; not nullNullPointerException - if the specified PrintStyle is nullpublic static void setDefaultPrintStyleForDetails(PrintStyle printStyle)
PrintStyle to be applied by the detailed stopwatch
formatter.
The object will be used by the following operations:
printStyle - the PrintStyle to be set; not nullNullPointerException - if the specified PrintStyle is nullpublic static MonitoredOperation monitorOperation(Runnable runnable)
Runnable, which can also be a lambda expression, and
collects metrics for all available counter types.
For example:
MonitoredOperation operation =Performetrics.monitorOperation(() -> myObj.exec());Duration elapsedTime = operation.elapsedTime(Type.WALL_CLOCK_TIME);
runnable - the Runnable to be run and monitoredMonitoredOperation, which can be used to retrieve the
collected results.public static MonitoredOperation monitorOperation(Runnable runnable, Counter.Type... types)
Runnable, which can also be a lambda expression, and
collects metrics for the specified counter type(s) only.
For example:
MonitoredOperation operation = Performetrics.monitorOperation(() -> myObj.exec(), Type.CPU_TIME);Duration elapsedTime = operation.elapsedTime(Type.CPU_TIME);
Note: If no type is specified, then all of the available types will be maintained.
runnable - the Runnable to be run and monitoredtypes - the counter types to be measured in the operationMonitoredOperation, which can be used to retrieve the
collected results.Copyright © 2023. All rights reserved.