Package com.bw.jtools.profiling
Class MethodProfiling
- java.lang.Object
-
- com.bw.jtools.profiling.MethodProfiling
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public final class MethodProfiling extends java.lang.Object implements java.lang.AutoCloseableHolds information of a currently profiled method/code-unit.
-
-
Field Summary
Fields Modifier and Type Field Description MethodProfilingInformationmethodThe method or code-unit that is profiled.protected booleannotRecursiveTrue if the call was not recursive.MeasurementValuestartTimeStart time in nanoseconds.protected MeasurementValueusedTimeUsed times in nanoseconds.
-
Constructor Summary
Constructors Constructor Description MethodProfiling()C'tor that automatically detects calling method and class.
Depending on platform this may an expensive operation.MethodProfiling(MethodProfilingInformation method)C'tor with method information instance (the fasted way).MethodProfiling(java.lang.String clazz, java.lang.String method)C'tor with class and method.
-
Method Summary
Modifier and Type Method Description voidclose()voidexception(java.lang.Throwable t)Profiles a exception.
Remind that "close" needs still to be called - following the AutoClosable pattern.MeasurementValuegetUsedTime()Get the used time in nanoseconds.
-
-
-
Field Detail
-
startTime
public final MeasurementValue startTime
Start time in nanoseconds.
-
usedTime
protected MeasurementValue usedTime
Used times in nanoseconds. Null if the call is not yet finished.
-
notRecursive
protected final boolean notRecursive
True if the call was not recursive.
-
method
public final MethodProfilingInformation method
The method or code-unit that is profiled.
-
-
Constructor Detail
-
MethodProfiling
public MethodProfiling()
C'tor that automatically detects calling method and class.
Depending on platform this may an expensive operation. SeeReflectionProfilingUtil.getStackTraceElement(int).
-
MethodProfiling
public MethodProfiling(java.lang.String clazz, java.lang.String method)C'tor with class and method.- Parameters:
clazz- The name of the module/class.method- The name of the method/code-unit.
-
MethodProfiling
public MethodProfiling(MethodProfilingInformation method)
C'tor with method information instance (the fasted way).- Parameters:
method- The method to profile.
-
-
Method Detail
-
getUsedTime
public final MeasurementValue getUsedTime()
Get the used time in nanoseconds.- Returns:
- The used time in nanoseconds or null if the call is not yet finished.
-
exception
public void exception(java.lang.Throwable t)
Profiles a exception.
Remind that "close" needs still to be called - following the AutoClosable pattern.- Parameters:
t- The Throwable.
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-