Package com.google.caliper.memory
Class ObjectGraphMeasurer
- java.lang.Object
-
- com.google.caliper.memory.ObjectGraphMeasurer
-
public final class ObjectGraphMeasurer extends Object
A tool that can qualitatively measure the footprint (e.g., number of objects, references, primitives) of a graph structure.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classObjectGraphMeasurer.FootprintThe footprint of an object graph.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectGraphMeasurer.Footprintmeasure(Object rootObject)Measures the footprint of the specified object graph.static ObjectGraphMeasurer.Footprintmeasure(Object rootObject, com.google.common.base.Predicate<Object> objectAcceptor)Measures the footprint of the specified object graph.
-
-
-
Method Detail
-
measure
public static ObjectGraphMeasurer.Footprint measure(Object rootObject)
Measures the footprint of the specified object graph. The object graph is defined by a root object and whatever object can be reached through that, excluding static fields,Classobjects, and fields defined inenums (all these are considered shared values, which should not contribute to the cost of any single object graph).Equivalent to
measure(rootObject, Predicates.alwaysTrue()).- Parameters:
rootObject- the root object of the object graph- Returns:
- the footprint of the object graph
-
measure
public static ObjectGraphMeasurer.Footprint measure(Object rootObject, com.google.common.base.Predicate<Object> objectAcceptor)
Measures the footprint of the specified object graph. The object graph is defined by a root object and whatever object can be reached through that, excluding static fields,Classobjects, and fields defined inenums (all these are considered shared values, which should not contribute to the cost of any single object graph), and any object for which the user-provided predicate returnsfalse.- Parameters:
rootObject- the root object of the object graphobjectAcceptor- a predicate that returnstruefor objects to be explored (and treated as part of the footprint), orfalseto forbid the traversal to traverse the given object- Returns:
- the footprint of the object graph
-
-