Package adams.core
Class SizeOf
- java.lang.Object
-
- adams.core.SizeOf
-
public class SizeOf extends Object
Helper class for measuring the size of objects using Maxim Zakharenkov's SizeOf agent or simply the length of the byte array generated by serialization.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLASS_SIZEOFthe class to use.protected static Booleanm_Availablewhether the SizeOf agent is available.protected static Classm_Classthe SizeOf agent class.protected static Methodm_FullSizeOfthe SizeOf agent method to use.protected static Methodm_FullSizeOfFilterthe SizeOf agent method to use (with filter).protected static Methodm_FullSizePerClassthe SizeOf agent method to use (per class).protected static Methodm_FullSizePerClassFilterthe SizeOf agent method to use (per class, with filter).static StringMETHOD_FULLSIZEOFthe method to use.static StringMETHOD_FULLSIZEPERCLASSthe method to use (per class).
-
Constructor Summary
Constructors Constructor Description SizeOf()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisSizeOfAgentAvailable()Returns whether the SizeOf agent is available or not.static voidmain(String[] args)For testing only.static intsizeOf(Object obj)Returns the size of an object.static intsizeOf(Object obj, sizeof.agent.Filter filter)Returns the size of an object.static intsizeOfAgent(Object obj)Returns the size of an object using the agent.static intsizeOfAgent(Object obj, sizeof.agent.Filter filter)Returns the size of an object using the agent.static Map<Class,sizeof.agent.Statistics>sizeOfAgentPerClass(Object obj)Returns the size and number of instances broken down by class for the given object.static Map<Class,sizeof.agent.Statistics>sizeOfAgentPerClass(Object obj, sizeof.agent.Filter filter)Returns the size and number of instances broken down by class for the given object.static intsizeOfSerialization(Object obj)Returns the size of an object using serialization.
-
-
-
Field Detail
-
CLASS_SIZEOF
public static final String CLASS_SIZEOF
the class to use.- See Also:
- Constant Field Values
-
METHOD_FULLSIZEOF
public static final String METHOD_FULLSIZEOF
the method to use.- See Also:
- Constant Field Values
-
METHOD_FULLSIZEPERCLASS
public static final String METHOD_FULLSIZEPERCLASS
the method to use (per class).- See Also:
- Constant Field Values
-
m_Available
protected static Boolean m_Available
whether the SizeOf agent is available.
-
m_Class
protected static Class m_Class
the SizeOf agent class.
-
m_FullSizeOf
protected static Method m_FullSizeOf
the SizeOf agent method to use.
-
m_FullSizeOfFilter
protected static Method m_FullSizeOfFilter
the SizeOf agent method to use (with filter).
-
m_FullSizePerClass
protected static Method m_FullSizePerClass
the SizeOf agent method to use (per class).
-
m_FullSizePerClassFilter
protected static Method m_FullSizePerClassFilter
the SizeOf agent method to use (per class, with filter).
-
-
Method Detail
-
isSizeOfAgentAvailable
public static boolean isSizeOfAgentAvailable()
Returns whether the SizeOf agent is available or not.- Returns:
- true if agent available
-
sizeOf
public static int sizeOf(Object obj)
Returns the size of an object.- Parameters:
obj- the object to measure- Returns:
- the size or -1 if failed to determine
- See Also:
sizeOfAgent(Object),sizeOfSerialization(Object)
-
sizeOf
public static int sizeOf(Object obj, sizeof.agent.Filter filter)
Returns the size of an object.- Parameters:
obj- the object to measurefilter- for filtering objects/fields- Returns:
- the size or -1 if failed to determine
- See Also:
sizeOfAgent(Object, Filter),sizeOfSerialization(Object)
-
sizeOfAgent
public static int sizeOfAgent(Object obj)
Returns the size of an object using the agent.- Parameters:
obj- the object to measure- Returns:
- the size or -1 if agent not available
-
sizeOfAgent
public static int sizeOfAgent(Object obj, sizeof.agent.Filter filter)
Returns the size of an object using the agent.- Parameters:
obj- the object to measurefilter- for filtering objects/fields- Returns:
- the size or -1 if agent not available
-
sizeOfAgentPerClass
public static Map<Class,sizeof.agent.Statistics> sizeOfAgentPerClass(Object obj)
Returns the size and number of instances broken down by class for the given object.- Parameters:
obj- the object to inspect- Returns:
- empty map if not available, otherwise the statistics per class
-
sizeOfAgentPerClass
public static Map<Class,sizeof.agent.Statistics> sizeOfAgentPerClass(Object obj, sizeof.agent.Filter filter)
Returns the size and number of instances broken down by class for the given object.- Parameters:
obj- the object to inspectfilter- for filtering objects/fields- Returns:
- empty map if not available, otherwise the statistics per class
-
sizeOfSerialization
public static int sizeOfSerialization(Object obj)
Returns the size of an object using serialization.- Parameters:
obj- the object to measure- Returns:
- the size or -1 if not serializable
-
main
public static void main(String[] args)
For testing only.- Parameters:
args- ignored
-
-