Class 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 property PERFORMANCE_LOG_ENABLE_PROPERTY with value "true".
    Author:
    Rene Schneider - initial API and implementation
    • 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
    • Constructor Detail

      • TestRunnerPerformanceLogger

        public TestRunnerPerformanceLogger()
    • 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 name
        anActionName - the action name
        aRunnable - 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 name
        anActionName - the action name
        aRunnable - 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 name
        anActionName - the action name
        aRunnable - 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 name
        anActionName - the action name
        aRunnable - 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 name
        anActionName - 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 name
        anActionName - the action name
      • log

        protected void log​(java.lang.String aLine)
        Logs something.
        Parameters:
        aLine - the textual line to be logged