Class TestRunnerPerformanceLogger
- java.lang.Object
-
- de.gebit.integrity.runner.logging.TestRunnerPerformanceLogger
-
public class TestRunnerPerformanceLogger extends java.lang.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_PROPERTY
with value "true".- Author:
- Rene Schneider - initial API and implementation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TestRunnerPerformanceLogger.RunnableWithException<E extends java.lang.Exception>
A runnable with no result that can throw an exception.static interface
TestRunnerPerformanceLogger.RunnableWithResult<R>
A runnable with a result.static interface
TestRunnerPerformanceLogger.RunnableWithResultAndException<R,E extends java.lang.Exception>
A runnable with a result that can throw an exception.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PERFORMANCE_LOG_CATEGORY_FORK
The performance log category used for fork related actions.static java.lang.String
PERFORMANCE_LOG_CATEGORY_INIT
The performance log category used for (script) loading/init-related actions.static java.lang.String
PERFORMANCE_LOG_CATEGORY_REMOTING
The performance log category used for remoting-related actions.static java.lang.String
PERFORMANCE_LOG_CATEGORY_RUNNER
The performance log category used for generic test runner related actions.static java.lang.String
PERFORMANCE_LOG_ENABLE_PROPERTY
The 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 java.lang.Exception>
voidexecuteAndLog(java.lang.String aCategoryName, java.lang.String anActionName, TestRunnerPerformanceLogger.RunnableWithException<E> aRunnable)
Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.<R> R
executeAndLog(java.lang.String aCategoryName, java.lang.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 java.lang.Exception>
RexecuteAndLog(java.lang.String aCategoryName, java.lang.String anActionName, TestRunnerPerformanceLogger.RunnableWithResultAndException<R,E> aRunnable)
Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.void
executeAndLog(java.lang.String aCategoryName, java.lang.String anActionName, java.lang.Runnable aRunnable)
Executes the provided runnable and logs the time required to execute it, if performance logging is enabled.protected void
log(java.lang.String aLine)
Logs something.protected void
logActionEnd(java.lang.String aCategoryName, java.lang.String anActionName, long aStartTime)
Logs the end of an action.protected long
logActionStart(java.lang.String aCategoryName, java.lang.String anActionName)
Logs the start of an action.
-
-
-
Field Detail
-
PERFORMANCE_LOG_CATEGORY_RUNNER
public static final java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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(java.lang.String aCategoryName, java.lang.String anActionName, java.lang.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(java.lang.String aCategoryName, java.lang.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 java.lang.Exception> void executeAndLog(java.lang.String aCategoryName, java.lang.String anActionName, TestRunnerPerformanceLogger.RunnableWithException<E> aRunnable) throws E extends java.lang.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 java.lang.Exception
-
executeAndLog
public <R,E extends java.lang.Exception> R executeAndLog(java.lang.String aCategoryName, java.lang.String anActionName, TestRunnerPerformanceLogger.RunnableWithResultAndException<R,E> aRunnable) throws E extends java.lang.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 java.lang.Exception
-
logActionStart
protected long logActionStart(java.lang.String aCategoryName, java.lang.String anActionName)
Logs the start of an action.- Parameters:
aCategoryName
- the category nameanActionName
- the action name
-
logActionEnd
protected void logActionEnd(java.lang.String aCategoryName, java.lang.String anActionName, long aStartTime)
Logs the end of an action.- Parameters:
aCategoryName
- the category nameanActionName
- the action name
-
log
protected void log(java.lang.String aLine)
Logs something.- Parameters:
aLine
- the textual line to be logged
-
-