Class AllocationMetrics


  • public class AllocationMetrics
    extends Object
    Immutable snapshot of the allocations counted during a simulation.
    • Method Detail

      • from

        public static AllocationMetrics from​(AllocationListener listener)
        Snapshots the counts a listener collected during simulation.
        Parameters:
        listener - the listener to read counts from
        Returns:
        the metrics snapshot
      • empty

        public static AllocationMetrics empty()
        Creates metrics with no recorded allocations.
        Returns:
        the empty metrics
      • getObjectCount

        public int getObjectCount()
        Returns:
        the number of object allocations
      • getArrayCount

        public int getArrayCount()
        Returns:
        the number of array allocations
      • getTotalCount

        public int getTotalCount()
        Returns:
        the object and array allocation counts summed
      • getAllocationsByType

        public Map<String,​Integer> getAllocationsByType()
        Returns:
        an unmodifiable map of type name to allocation count
      • getCountForType

        public int getCountForType​(String typeName)
        Looks up one type's tally.
        Parameters:
        typeName - the allocated type to look up
        Returns:
        the count for that type, or 0 if it was never allocated
      • getDistinctTypeCount

        public int getDistinctTypeCount()
        Returns:
        the number of distinct types allocated
      • hasAllocations

        public boolean hasAllocations()
        Returns:
        true if any object or array was allocated
      • getMostAllocatedType

        public String getMostAllocatedType()
        Scans the per-type tally for the highest count.
        Returns:
        the type name allocated most often, or null if nothing was allocated
      • combine

        public AllocationMetrics combine​(AllocationMetrics other)
        Adds the counts and per-type tallies of both metrics.
        Parameters:
        other - the metrics to add
        Returns:
        a new metrics holding the summed counts