Class TestRunnerPerformanceLogger
- java.lang.Object
-
- de.gebit.integrity.runner.logging.TestRunnerPerformanceLogger
-
public class TestRunnerPerformanceLogger extends Object
This performance logging service is used to execute several performance-critical segments of test execution. It allows to print out start/end markers for the performance-relevant sections as well as their (total) duration.
By default, this data is NOT logged. You can enable logging by specifying the system propertyPERFORMANCE_LOG_ENABLE_PROPERTYwith value "true".- Author:
- Rene Schneider - initial API and implementation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTestRunnerPerformanceLogger.RunnableWithException<E extends Exception>A runnable with no result that can throw an exception.static interfaceTestRunnerPerformanceLogger.RunnableWithResult<R>A runnable with a result.static interfaceTestRunnerPerformanceLogger.RunnableWithResultAndException<R,E extends Exception>A runnable with a result that can throw an exception.
-
Field Summary
Fields Modifier and Type Field Description static StringPERFORMANCE_LOG_CATEGORY_FORKThe performance log category used for fork related actions.static StringPERFORMANCE_LOG_CATEGORY_INITThe performance log category used for (script) loading/init-related actions.static StringPERFORMANCE_LOG_CATEGORY_REMOTINGThe performance log category used for remoting-related actions.static StringPERFORMANCE_LOG_CATEGORY_RUNNERThe performance log category used for generic test runner related actions.static StringPERFORMANCE_LOG_ENABLE_PROPERTYThe system property to specify to enable performance logging.
-
Constructor Summary
Constructors Constructor Description TestRunnerPerformanceLogger()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <E extends Exception>
voidexecuteAndLog(String aCategoryName, String anActionName, TestRunnerPerformanceLogger.RunnableWithException<E> aRunnable)Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.<R> RexecuteAndLog(String aCategoryName, String anActionName, TestRunnerPerformanceLogger.RunnableWithResult<R> aRunnable)Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.<R,E extends Exception>
RexecuteAndLog(String aCategoryName, String anActionName, TestRunnerPerformanceLogger.RunnableWithResultAndException<R,E> aRunnable)Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.voidexecuteAndLog(String aCategoryName, String anActionName, Runnable aRunnable)Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.protected voidlog(String aLine)Logs something.protected voidlogActionEnd(String aCategoryName, String anActionName, long aStartTime)Logs the end of an action.protected longlogActionStart(String aCategoryName, String anActionName)Logs the start of an action.
-
-
-
Field Detail
-
PERFORMANCE_LOG_CATEGORY_RUNNER
public static final String PERFORMANCE_LOG_CATEGORY_RUNNER
The performance log category used for generic test runner related actions.- See Also:
- Constant Field Values
-
PERFORMANCE_LOG_CATEGORY_FORK
public static final String PERFORMANCE_LOG_CATEGORY_FORK
The performance log category used for fork related actions.- See Also:
- Constant Field Values
-
PERFORMANCE_LOG_CATEGORY_REMOTING
public static final String PERFORMANCE_LOG_CATEGORY_REMOTING
The performance log category used for remoting-related actions.- See Also:
- Constant Field Values
-
PERFORMANCE_LOG_CATEGORY_INIT
public static final String PERFORMANCE_LOG_CATEGORY_INIT
The performance log category used for (script) loading/init-related actions.- See Also:
- Constant Field Values
-
PERFORMANCE_LOG_ENABLE_PROPERTY
public static final String PERFORMANCE_LOG_ENABLE_PROPERTY
The system property to specify to enable performance logging.- See Also:
- Constant Field Values
-
-
Method Detail
-
executeAndLog
public void executeAndLog(String aCategoryName, String anActionName, Runnable aRunnable)
Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.- Parameters:
aCategoryName- the category nameanActionName- the action nameaRunnable- the runnable to execute
-
executeAndLog
public <R> R executeAndLog(String aCategoryName, String anActionName, TestRunnerPerformanceLogger.RunnableWithResult<R> aRunnable)
Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.- Parameters:
aCategoryName- the category nameanActionName- the action nameaRunnable- the runnable to execute
-
executeAndLog
public <E extends Exception> void executeAndLog(String aCategoryName, String anActionName, TestRunnerPerformanceLogger.RunnableWithException<E> aRunnable) throws E extends Exception
Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.- Parameters:
aCategoryName- the category nameanActionName- the action nameaRunnable- the runnable to execute- Throws:
E extends Exception
-
executeAndLog
public <R,E extends Exception> R executeAndLog(String aCategoryName, String anActionName, TestRunnerPerformanceLogger.RunnableWithResultAndException<R,E> aRunnable) throws E extends Exception
Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.- Parameters:
aCategoryName- the category nameanActionName- the action nameaRunnable- the runnable to execute- Throws:
E extends Exception
-
logActionStart
protected long logActionStart(String aCategoryName, String anActionName)
Logs the start of an action.- Parameters:
aCategoryName- the category nameanActionName- the action name
-
logActionEnd
protected void logActionEnd(String aCategoryName, String anActionName, long aStartTime)
Logs the end of an action.- Parameters:
aCategoryName- the category nameanActionName- the action name
-
log
protected void log(String aLine)
Logs something.- Parameters:
aLine- the textual line to be logged
-
-