Class ProfilerAspect


  • public class ProfilerAspect
    extends java.lang.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. .
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  ProfilerAspect.Block<T>  
    • Constructor Summary

      Constructors 
      Constructor Description
      ProfilerAspect()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String humanReadable​(long milliseconds)
      Converts the input milliseconds in a human readable format (e.g.
      java.lang.Object logAroundByMethod​(org.aspectj.lang.ProceedingJoinPoint joinPoint, Profile profile)  
      static <T> T wrapProfile​(java.lang.Class<?> clazz, java.lang.String signature, ProfilerAspect.Block<T> block)
      Sometimes adding an annotation may not work, e.g.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ProfilerAspect

        public ProfilerAspect()
    • Method Detail

      • logAroundByMethod

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

        public static <T> T wrapProfile​(java.lang.Class<?> clazz,
                                        java.lang.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 java.lang.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