Class PathMetrics
- java.lang.Object
-
- com.tonic.analysis.simulation.metrics.PathMetrics
-
public class PathMetrics extends Object
Immutable snapshot of the control-flow statistics gathered during a simulation.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PathMetricscombine(PathMetrics other)Adds every counter of another snapshot to this one.static PathMetricsempty()static PathMetricsfrom(ControlFlowListener listener)Captures the counters a listener has accumulated so far.doublegetAverageVisitsPerBlock()Divides total block entries by distinct blocks visited.intgetBlocksVisited()intgetBranchCount()intgetComplexityIndicator()Computes a McCabe-like score of branches plus switches plus one.intgetDistinctTransitions()intgetGotoCount()intgetReturnCount()intgetRevisitedBlocks()intgetSwitchCount()intgetThrowCount()intgetTotalBlockEntries()intgetTotalControlFlowInstructions()Sums the branch, switch, goto, return, and throw counts.booleanhasExceptionHandling()booleanhasLoops()StringtoString()
-
-
-
Method Detail
-
from
public static PathMetrics from(ControlFlowListener listener)
Captures the counters a listener has accumulated so far.- Parameters:
listener- listener to read- Returns:
- the captured metrics
-
empty
public static PathMetrics empty()
- Returns:
- metrics with every counter at zero
-
getBlocksVisited
public int getBlocksVisited()
- Returns:
- the number of distinct blocks visited
-
getTotalBlockEntries
public int getTotalBlockEntries()
- Returns:
- the number of block entries, counting revisits
-
getBranchCount
public int getBranchCount()
- Returns:
- the number of branch instructions executed
-
getSwitchCount
public int getSwitchCount()
- Returns:
- the number of switch instructions executed
-
getGotoCount
public int getGotoCount()
- Returns:
- the number of goto instructions executed
-
getReturnCount
public int getReturnCount()
- Returns:
- the number of return instructions executed
-
getThrowCount
public int getThrowCount()
- Returns:
- the number of throw instructions executed
-
getTotalControlFlowInstructions
public int getTotalControlFlowInstructions()
Sums the branch, switch, goto, return, and throw counts.- Returns:
- the total control-flow instruction count
-
getDistinctTransitions
public int getDistinctTransitions()
- Returns:
- the number of distinct block-to-block transitions taken
-
getRevisitedBlocks
public int getRevisitedBlocks()
- Returns:
- the number of blocks entered more than once
-
getAverageVisitsPerBlock
public double getAverageVisitsPerBlock()
Divides total block entries by distinct blocks visited.- Returns:
- the average entries per block, or 0 if no block was visited
-
hasLoops
public boolean hasLoops()
- Returns:
- true if at least one block was revisited, which suggests a loop
-
hasExceptionHandling
public boolean hasExceptionHandling()
- Returns:
- true if at least one throw was executed
-
getComplexityIndicator
public int getComplexityIndicator()
Computes a McCabe-like score of branches plus switches plus one.- Returns:
- the complexity indicator
-
combine
public PathMetrics combine(PathMetrics other)
Adds every counter of another snapshot to this one.- Parameters:
other- metrics to add- Returns:
- a new snapshot holding the summed counters
-
-