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

    • 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:
    • PERFORMANCE_LOG_CATEGORY_FORK

      public static final String PERFORMANCE_LOG_CATEGORY_FORK
      The performance log category used for fork related actions.
      See Also:
    • PERFORMANCE_LOG_CATEGORY_REMOTING

      public static final String PERFORMANCE_LOG_CATEGORY_REMOTING
      The performance log category used for remoting-related actions.
      See Also:
    • 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:
    • PERFORMANCE_LOG_ENABLE_PROPERTY

      public static final String PERFORMANCE_LOG_ENABLE_PROPERTY
      The system property to specify to enable performance logging.
      See Also:
  • Constructor Details

    • TestRunnerPerformanceLogger

      public TestRunnerPerformanceLogger()
  • Method Details

    • 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 name
      anActionName - the action name
      aRunnable - 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 name
      anActionName - the action name
      aRunnable - the runnable to execute
    • executeAndLog

      public <E extends Exception> void executeAndLog(String aCategoryName, String anActionName, TestRunnerPerformanceLogger.RunnableWithException<E> aRunnable) throws E
      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
    • executeAndLog

      public <R, E extends Exception> R executeAndLog(String aCategoryName, String anActionName, TestRunnerPerformanceLogger.RunnableWithResultAndException<R,E> aRunnable) throws E
      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
    • logActionStart

      protected long logActionStart(String aCategoryName, String anActionName)
      Logs the start of an action.
      Parameters:
      aCategoryName - the category name
      anActionName - the action name
    • logActionEnd

      protected void logActionEnd(String aCategoryName, String anActionName, long aStartTime)
      Logs the end of an action.
      Parameters:
      aCategoryName - the category name
      anActionName - the action name
    • log

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