Package net.obvj.performetrics
Class Performetrics
- java.lang.Object
-
- net.obvj.performetrics.Performetrics
-
public class Performetrics extends Object
A Facade class meant to provide a simple interface for common parameters setup and other operations.- Since:
- 2.0.0
- Author:
- oswaldo.bapvic.jr
-
-
Field Summary
Fields Modifier and Type Field Description static List<Counter.Type>ALL_TYPESA list containing all the available counter types.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Configurationconfiguration()Returns the currentConfiguration.static MonitoredRunnablemonitorOperation(Runnable runnable)Runs the specifiedRunnable, which can also be a lambda expression, and collects metrics for all available counter types.static MonitoredRunnablemonitorOperation(Runnable runnable, Counter.Type... types)Runs the specifiedRunnable, which can also be a lambda expression, and collects metrics for the specified counter type(s) only.static voidsetDefaultConversionMode(ConversionMode conversionMode)Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setConversionMode(ConversionMode)instead.static voidsetDefaultPrintStyle(PrintStyle printStyle)Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setPrintStyle(PrintStyle)instead.static voidsetDefaultPrintStyleForDetails(PrintStyle printStyle)Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setPrintStyleForDetails(PrintStyle)instead.static voidsetDefaultPrintStyleForSummary(PrintStyle printStyle)Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setPrintStyleForSummary(PrintStyle)instead.static voidsetScale(int scale)Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setScale(int)instead.
-
-
-
Field Detail
-
ALL_TYPES
public static final List<Counter.Type> ALL_TYPES
A list containing all the available counter types.- Since:
- 2.5.0
-
-
Method Detail
-
configuration
public static Configuration configuration()
Returns the currentConfiguration.- Returns:
- the current configuration
- Since:
- 2.5.3
-
setDefaultConversionMode
@Deprecated(since="2.5.3", forRemoval=true) public static void setDefaultConversionMode(ConversionMode conversionMode)
Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setConversionMode(ConversionMode)instead.Sets a conversion mode to be applied by supported operations if no specific mode is set.- Parameters:
conversionMode- theConversionModeto set
-
setScale
@Deprecated(since="2.5.3", forRemoval=true) public static void setScale(int scale)
Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setScale(int)instead.Sets a maximum number of decimal places to be applied if double-precision conversion mode is set.- Parameters:
scale- a number between 0 and 16 to be set- Throws:
IllegalArgumentException- if a number outside the allowed range is received
-
setDefaultPrintStyle
@Deprecated(since="2.5.3", forRemoval=true) public static void setDefaultPrintStyle(PrintStyle printStyle)
Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setPrintStyle(PrintStyle)instead.Defines the defaultPrintStyleto be applied when no style is specified.The object will be used by the following operations:
- Parameters:
printStyle- thePrintStyleto be set; not null- Throws:
NullPointerException- if the specifiedPrintStyleis null- Since:
- 2.4.0
-
setDefaultPrintStyleForSummary
@Deprecated(since="2.5.3", forRemoval=true) public static void setDefaultPrintStyleForSummary(PrintStyle printStyle)
Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setPrintStyleForSummary(PrintStyle)instead.Defines the defaultPrintStyleto be applied by the summarized stopwatch formatter.The object will be used by the following operation:
- Parameters:
printStyle- thePrintStyleto be set; not null- Throws:
NullPointerException- if the specifiedPrintStyleis null- Since:
- 2.2.1
-
setDefaultPrintStyleForDetails
@Deprecated(since="2.5.3", forRemoval=true) public static void setDefaultPrintStyleForDetails(PrintStyle printStyle)
Deprecated, for removal: This API element is subject to removal in a future version.UsePerformetrics.configuration().setPrintStyleForDetails(PrintStyle)instead.Defines the defaultPrintStyleto be applied by the detailed stopwatch formatter.The object will be used by the following operations:
- Parameters:
printStyle- thePrintStyleto be set; not null- Throws:
NullPointerException- if the specifiedPrintStyleis null- Since:
- 2.2.1
-
monitorOperation
public static MonitoredRunnable monitorOperation(Runnable runnable)
Runs the specifiedRunnable, which can also be a lambda expression, and collects metrics for all available counter types.For example:
MonitoredRunnable runnable =Performetrics.monitorOperation(() -> myObj.exec());Duration elapsedTime = runnable.elapsedTime(Type.WALL_CLOCK_TIME);- Parameters:
runnable- theRunnableto be run and monitored- Returns:
- the resulting
MonitoredRunnable, which can be used to retrieve the collected results. - Since:
- 2.2.0
-
monitorOperation
public static MonitoredRunnable monitorOperation(Runnable runnable, Counter.Type... types)
Runs the specifiedRunnable, which can also be a lambda expression, and collects metrics for the specified counter type(s) only.For example:
MonitoredRunnable runnable = Performetrics.monitorOperation(() -> myObj.exec(), Type.CPU_TIME);Duration elapsedTime = runnable.elapsedTime(Type.CPU_TIME);Note: If no type is specified, then all of the available types will be maintained.
Note: If the provided
Runnablethrows an exception during execution, the method will not be able to generate the monitoredMonitoredRunnable. In this case, using theMonitoredRunnableclass is recommended. Then, the exception can be handled as necessary.- Parameters:
runnable- theRunnableto be run and monitoredtypes- the counter types to be measured in the operation- Returns:
- the resulting
MonitoredRunnable, which can be used to retrieve the collected results. - Since:
- 2.2.0
-
-