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 String
CLASS_SIZEOF
the class to use.protected static Boolean
m_Available
whether the SizeOf agent is available.protected static Class
m_Class
the SizeOf agent class.protected static Method
m_FullSizeOf
the SizeOf agent method to use.protected static Method
m_FullSizeOfFilter
the SizeOf agent method to use (with filter).protected static Method
m_FullSizePerClass
the SizeOf agent method to use (per class).protected static Method
m_FullSizePerClassFilter
the SizeOf agent method to use (per class, with filter).static String
METHOD_FULLSIZEOF
the method to use.static String
METHOD_FULLSIZEPERCLASS
the 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 boolean
isSizeOfAgentAvailable()
Returns whether the SizeOf agent is available or not.static void
main(String[] args)
For testing only.static int
sizeOf(Object obj)
Returns the size of an object.static int
sizeOf(Object obj, sizeof.agent.Filter filter)
Returns the size of an object.static int
sizeOfAgent(Object obj)
Returns the size of an object using the agent.static int
sizeOfAgent(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 int
sizeOfSerialization(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
-
-