Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## avrora.sim.util
Class BranchCounter

    java.lang.Object
      avrora.sim.util.BranchCounter

All Implemented Interfaces:
  Simulator.Probe

public class BranchCounter
extends java.lang.Object
implements Simulator.Probe

The `BranchCounter` class is a profiling probe that can be inserted at a branch instruction to count the number of times the branch is taken and not taken. It demonstrates the ability to inspect the state of the program after the execution of a program. It determines whether the branch was taken by inspecting the program counter of the new state. If the program counter is not equal to the instruction following the branch, then the branch was taken.

See Also:
  `Counter`

Field Summary
`int` | `nottakenCount` This field tracks the number of times the branch is not taken.
`int` | `takenCount` This field tracks the number of times the branch is taken.

Constructor Summary
`BranchCounter()`

Method Summary
`void` | `fireAfter(Instr i, int address, State state)` The `fireAfter()` method is called after the probed instruction executes.
`void` | `fireBefore(Instr i, int address, State state)` The `fireBefore()` method is called before the probed instruction executes.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### takenCount

    public int takenCount

  This field tracks the number of times the branch is taken. It is incremented in the `fireAfter` method if the branch was taken.

### nottakenCount

    public int nottakenCount

  This field tracks the number of times the branch is not taken. It is incremented in the `fireAfter` method if the branch was not taken.

Constructor Detail

### BranchCounter

    public BranchCounter()

Method Detail

### fireBefore

    public void fireBefore(Instr i,
                           int address,
                           State state)

  The `fireBefore()` method is called before the probed instruction executes. In the implementation of the branch counter, nothing needs to be done before the branch is executed, so this method does nothing.

  Specified by:
    `fireBefore` in interface `Simulator.Probe`
  Parameters:
    `i` - the instruction being probed
    `address` - the address at which this instruction resides
    `state` - the state of the simulation

### fireAfter

    public void fireAfter(Instr i,
                          int address,
                          State state)

  The `fireAfter()` method is called after the probed instruction executes. In the implementation of the branch counter, the counter determines whether the branch was taken by inspecting the program counter of the new state. If the program counter is not equal to the instruction following the branch, then the branch was taken.

  Specified by:
    `fireAfter` in interface `Simulator.Probe`
  Parameters:
    `i` - the instruction being probed
    `address` - the address at which this instruction resides
    `state` - the state of the simulation

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD