Class StackMetrics
- java.lang.Object
-
- com.tonic.analysis.simulation.metrics.StackMetrics
-
public class StackMetrics extends Object
Immutable operand stack operation counts collected during simulation.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StackMetricscombine(StackMetrics other)Sums the operation counts of both metrics and keeps the deeper maximum depth.static StackMetricsempty()Creates metrics with every count at zero.static StackMetricsfrom(StackOperationListener listener)Snapshots the counts a listener accumulated.intgetDupCount()intgetMaxDepth()intgetNetChange()intgetPopCount()intgetPushCount()intgetSwapCount()intgetTotalOperations()booleanhasStackGrowth()StringtoString()
-
-
-
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
-
-