Class ProfilerAspect


  • public class ProfilerAspect
    extends Object
    Aspect to measure the execution time of methods. Simply annotate the class or method to measure with Profile. In order to get this to work, a bean of type ProfilerAspect must be in the current Spring Application Context and AOP must be enabled, e.g. .
    • Constructor Detail

      • ProfilerAspect

        public ProfilerAspect()
    • Method Detail

      • logAroundByMethod

        public Object logAroundByMethod​(org.aspectj.lang.ProceedingJoinPoint joinPoint,
                                        Profile profile)
                                 throws Throwable
        Throws:
        Throwable
      • wrapProfile

        public static <T> T wrapProfile​(Class<?> clazz,
                                        String signature,
                                        ProfilerAspect.Block<T> block)
        Sometimes adding an annotation may not work, e.g. the class is not managed by spring. This method allows to wrap any statements to be measured, by simply wrap it into a ProfilerAspect.Block object
        Returns:
        the return of the block. If no return is required, simply return null.
      • humanReadable

        public static String humanReadable​(long milliseconds)
        Converts the input milliseconds in a human readable format (e.g. 1s 100ms)
        Parameters:
        milliseconds - The ms to convert
        Returns:
        The human readable format, e.g. 2h 15m 3s 150ms