Class StackMetrics


  • public class StackMetrics
    extends Object
    Immutable operand stack operation counts collected during simulation.
    • Method Detail

      • from

        public static StackMetrics from​(StackOperationListener listener)
        Snapshots the counts a listener accumulated.
        Parameters:
        listener - the listener to read counts from
        Returns:
        metrics holding that listener's counts
      • empty

        public static StackMetrics empty()
        Creates metrics with every count at zero.
        Returns:
        all-zero metrics
      • getPushCount

        public int getPushCount()
        Returns:
        the number of pushes
      • getPopCount

        public int getPopCount()
        Returns:
        the number of pops
      • getDupCount

        public int getDupCount()
        Returns:
        the number of dup operations
      • getSwapCount

        public int getSwapCount()
        Returns:
        the number of swap operations
      • getMaxDepth

        public int getMaxDepth()
        Returns:
        the deepest stack observed
      • getTotalOperations

        public int getTotalOperations()
        Returns:
        pushes, pops, dups and swaps summed
      • getNetChange

        public int getNetChange()
        Returns:
        pushes minus pops
      • hasStackGrowth

        public boolean hasStackGrowth()
        Returns:
        true when more pushes than pops were counted
      • combine

        public StackMetrics combine​(StackMetrics other)
        Sums the operation counts of both metrics and keeps the deeper maximum depth.
        Parameters:
        other - the metrics to add
        Returns:
        the combined metrics