public class ManagedCounterData extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ManagedCounterData.Counter
Auxiliary class
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
automaticallyGrowCounters |
protected InstrumentedEventCounterManager |
counterManager
Basic block instrumentation stores its counters using an
abstracted counter allocation technique (a counterManager)
|
protected int |
handle
When a data object is registered with a counter manager, it is
given an id, which is stored here.
|
protected int |
numCounters
How many counters are needed by this data?
|
Constructor and Description |
---|
ManagedCounterData(InstrumentedEventCounterManager counterManager) |
Modifier and Type | Method and Description |
---|---|
void |
automaticallyGrowCounters(boolean autoGrow)
Tell the data to automatically expand the counters if there is a
request to count an event that is greater than the current size.
|
Instruction |
createEventCounterInstruction(int counterNumber)
Create a place holder instruction to represent an increment of a
particular counted event.
|
(package private) Instruction |
createEventCounterInstruction(int counterNumber,
double incrementValue)
Create a place holder instruction to represent the counted event.
|
double |
getCounter(int counterNumber)
Return the count for the given (relative) index
|
InstrumentedEventCounterManager |
getCounterManager()
Return the counter manager for this data.
|
int |
getHandle()
Counter Managers give id's that identify the counter space they
have given to each data.
|
int |
getNumCounters()
Return the number of counters currently allocated for this data
|
void |
initializeCounters(int countersNeeded)
This method must be called before creating any counters for this
data.
|
(package private) void |
report(CounterNameFunction f)
This method prints the (sorted) nonzero elements a counter
array.
|
void |
resizeCounters(int countersNeeded)
Used to reset the number of counters for this data
|
void |
setCounter(int counterNumber,
double value)
Set the count for the given index
|
private void |
sort(Vector<?> v)
Sorts a
Vector<Counter> by decreasing count. |
private <T> void |
swap(Vector<T> vec,
int i,
int j) |
protected int numCounters
protected int handle
protected InstrumentedEventCounterManager counterManager
protected boolean automaticallyGrowCounters
ManagedCounterData(InstrumentedEventCounterManager counterManager)
counterManager
- The counterManager that will provide the counter spacepublic void initializeCounters(int countersNeeded)
countersNeeded
- How many counters are needed by this datapublic void automaticallyGrowCounters(boolean autoGrow)
autoGrow
- Whether the counters should grow automatically.public void resizeCounters(int countersNeeded)
countersNeeded
- The number of counters neededpublic double getCounter(int counterNumber)
counterNumber
- The event number within the datapublic void setCounter(int counterNumber, double value)
counterNumber
- The event number within the datavalue
- The new value of the counterpublic int getNumCounters()
public int getHandle()
public InstrumentedEventCounterManager getCounterManager()
public Instruction createEventCounterInstruction(int counterNumber)
counterNumber
- The number of the counter to incrementInstruction createEventCounterInstruction(int counterNumber, double incrementValue)
counterNumber
- The number of the counter to incrementincrementValue
- The value to add to the given counterfinal void report(CounterNameFunction f)
f
- a function that gets the "name" for each counterprivate void sort(Vector<?> v)
Vector<Counter>
by decreasing count.
(code borrowed from InstructionSampler.java)
Shell sort
Reference: "The C Programming Language", Kernighan & Ritchie, p. 116
v
- the vector to sort