Package one.xingyi.profile
Class Profile
java.lang.Object
one.xingyi.profile.Profile
- All Implemented Interfaces:
IProfile,IProfileInfo,ProfileMBean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a child of this profile.voidclear()intgetCount()getPath()longlonginfo()json()<T,E extends Exception>
Tprofile(SupplierWithExceptionE<T, E> fn) Time how longs it takes to run the supplier.The profiler is registered as a MBean.<E extends Exception>
voidrun(RunnableWithExceptionE<E> fn) Time how longs it takes to run the runnable.withErrorHandler(Consumer<Exception> errorHandler) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface one.xingyi.profile.IProfileInfo
getAvgMs
-
Constructor Details
-
Profile
public Profile()
-
-
Method Details
-
profile
Description copied from interface:IProfileTime how longs it takes to run the supplier. The result of the supplier is returned. -
run
Description copied from interface:IProfileTime how longs it takes to run the runnable. -
child
Description copied from interface:IProfileCreate a child of this profile. There are three main reasons for doing this:- In a class, with the name of the class as the 'name'. This would often be registered as an mbean (call .registerMBean)
- For a particular method, with the name of the method as the 'name'. Unless the class is a 'god class' with lots of 'entry level' methods in it this wouldn't normally be registered as a MBean
- Sometimes methods are huge... 100s of lines. We can profile separate parts of this, and we can give those a name. Often this is a clue you should refactor the method!
-
registerMBean
Description copied from interface:IProfileThe profiler is registered as a MBean. If you call it twice it will throw exceptions, so usually this is done to 'static final' profile- Specified by:
registerMBeanin interfaceIProfile
-
withErrorHandler
- Specified by:
withErrorHandlerin interfaceIProfile
-
getCount
public int getCount()- Specified by:
getCountin interfaceIProfileInfo
-
getTotalMs
public long getTotalMs()- Specified by:
getTotalMsin interfaceIProfileInfo
-
getPath
- Specified by:
getPathin interfaceIProfileInfo
-
getSnapshotMs
public long getSnapshotMs()- Specified by:
getSnapshotMsin interfaceIProfileInfo
-
info
-
json
- Specified by:
jsonin interfaceProfileMBean
-
clear
public void clear()- Specified by:
clearin interfaceProfileMBean
-