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 ProgramTimeProfiler

    java.lang.Object
      avrora.sim.util.ProgramTimeProfiler

All Implemented Interfaces:
  Simulator.Probe

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

The `ProgramProfiler` class implements a probe that can be used to profile pieces of the program or the whole program. It maintains a simple array of `long` that stores the cumulative cycles consumed for each instruction in the program.

See Also:
  `Counter`

Field Summary
`long[]` | `itime` The `itime` field stores the cumulative number of cycles consumed for each instruction in the program.
`Program` | `program` The `program` field stores a reference to the program being profiled.
`protected long` | `timeBegan`

Constructor Summary
`ProgramTimeProfiler(Program p)` The constructor for the program profiler constructs the required internal state to store the cycle counts of each instruction.

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

### program

    public final Program program

  The `program` field stores a reference to the program being profiled.

### itime

    public final long[] itime

  The `itime` field stores the cumulative number of cycles consumed for each instruction in the program. It is indexed by byte addresses. Thus `itime[addr]` corresponds to the time for the instruction at `program.getInstr(addr)`.

### timeBegan

    protected long timeBegan

Constructor Detail

### ProgramTimeProfiler

    public ProgramTimeProfiler(Program p)

  The constructor for the program profiler constructs the required internal state to store the cycle counts of each instruction.

Parameters:
  `p` - the program to profile

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 program profiler, it simply remembers the timestamp at the beginning of the instruction.

  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 profiler, it counts the number of cycles consumed in executing this instruction and adds it to the count for this instruction.

  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