Class TraceMethod


  • public class TraceMethod
    extends Object
    Outlines a method for tracing.
    Author:
    Christof Reichardt
    • Constructor Detail

      • TraceMethod

        public TraceMethod​(String signature)
        Constructs a TraceMethod with the specified signature.
        Parameters:
        signature - the signature of the TraceMethod
      • TraceMethod

        @Deprecated
        public TraceMethod​(String signature,
                           Class<?> clazz)
        Deprecated.
        Constructs a TraceMethod with the specified signature and class.
        Parameters:
        signature - the signature of the TraceMethod
        clazz - the class of the TraceMethod
      • TraceMethod

        public TraceMethod​(String returnType,
                           Object object,
                           String methodSignature)
        Constructs a TraceMethod with the specified signature.
        Parameters:
        returnType - the return type of the method as string representation
        object - the object that owns the method
        methodSignature - the remaining method signature (without return type) inclusive parameter as string representation
      • TraceMethod

        public TraceMethod​(String returnType,
                           Class<?> clazz,
                           String methodSignature)
        Constructs a TraceMethod with the specified signature.
        Parameters:
        returnType - the return type of the method as string representation
        clazz - the class to which that method belong
        methodSignature - the remaining method signature (without return type) inclusive parameter as string representation
    • Method Detail

      • getSignature

        public String getSignature()
        This is the string representation of the method signature. It is composed of the return type, the owning class and the remaining method signature (method name and list of parameters).
        Returns:
        the signature
      • getElapsedTime

        public long getElapsedTime()
        This is the elapsed time in milliseconds since the construction of the TraceMethod until the moment the TraceMethod is popped from the stack again.
        Returns:
        the elapsedTime
      • getElapsedCpuTime

        public long getElapsedCpuTime()
        This is the elapsed CPU time since the construction of the TraceMethod until the moment the TraceMethod is popped from the stack again. That is only the execution time of the current thread on the CPU will be measured. Suppose the scheduler decides to switch the contect to another thread during the execution of the method. This time doesn't count. Or the method itself passes the actual work to another thread. That doesn't count either.
        Returns:
        the elapsedCpuTime
      • getClazz

        public Class<?> getClazz()
        The class owning the method.
        Returns:
        the clazz
      • getMethodName

        public String getMethodName()
        The method name inclusive list of parameters.
        Returns:
        the methodName
      • stopTime

        public void stopTime()
        Stops the elapsed (cpu) time since creation of this TraceMethod instance.