org.jikesrvm.adaptive.measurements.instrumentation
Class StringEventCounterData

java.lang.Object
  extended by org.jikesrvm.adaptive.measurements.instrumentation.ManagedCounterData
      extended by org.jikesrvm.adaptive.measurements.instrumentation.StringEventCounterData
All Implemented Interfaces:
Reportable
Direct Known Subclasses:
YieldpointCounterData

public class StringEventCounterData
extends ManagedCounterData
implements Reportable

A generic data object that maps strings to counters. The key method is "Instruction getCounterInstructionForEvent(String)" which, given a string, returns a counter instruction that increments the corresponding counter for that string.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jikesrvm.adaptive.measurements.instrumentation.ManagedCounterData
ManagedCounterData.Counter
 
Field Summary
(package private)  String dataName
          A string description of this data;
(package private) static boolean DEBUG
           
(package private)  int eventNumber
          Used to keep track of how many counters have been used so far.
protected  Hashtable<String,Integer> stringToCounterMap
          Map strings to a counter location
 
Fields inherited from class org.jikesrvm.adaptive.measurements.instrumentation.ManagedCounterData
automaticallyGrowCounters, counterManager, handle, numCounters
 
Constructor Summary
StringEventCounterData(InstrumentedEventCounterManager manager, String name)
          Constructor
 
Method Summary
protected static String doubleToString(double num)
          Convert a double to string with maximum precision.
 int getCounterIndexForString(String str)
          For a given string, return the number of the counter associated with this string.
 Instruction getCounterInstructionForEvent(String event)
          Given a string, find or create the counter associated and return and instruction to increment that counter.
 Instruction getCounterInstructionForEvent(String event, double incrementValue)
          Given a string, find or create the counter associated and return and instruction to increment that counter.
 int getOrCreateCounterIndexForString(String str)
          For a given string, return the number of the counter associated with this string.
 void report()
          Print a report at the end of execution
 void reset()
          reset (clear) data set being gathered
 
Methods inherited from class org.jikesrvm.adaptive.measurements.instrumentation.ManagedCounterData
automaticallyGrowCounters, createEventCounterInstruction, createEventCounterInstruction, getCounter, getCounterManager, getHandle, getNumCounters, initializeCounters, report, resizeCounters, setCounter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

static final boolean DEBUG
See Also:
Constant Field Values

stringToCounterMap

protected final Hashtable<String,Integer> stringToCounterMap
Map strings to a counter location


dataName

final String dataName
A string description of this data;


eventNumber

int eventNumber
Used to keep track of how many counters have been used so far.

Constructor Detail

StringEventCounterData

StringEventCounterData(InstrumentedEventCounterManager manager,
                       String name)
Constructor

Parameters:
manager - The manager that will provide the counter space
Method Detail

getCounterInstructionForEvent

public Instruction getCounterInstructionForEvent(String event)
Given a string, find or create the counter associated and return and instruction to increment that counter.

Parameters:
event - The name of the event
Returns:
An instruction to increment the count associated with the event.

getCounterInstructionForEvent

public Instruction getCounterInstructionForEvent(String event,
                                                 double incrementValue)
Given a string, find or create the counter associated and return and instruction to increment that counter.

Parameters:
event - The name of the event
incrementValue - The value to add to counter
Returns:
An instruction that will update the count associated with the event.

doubleToString

protected static String doubleToString(double num)
Convert a double to string with maximum precision.

Parameters:
num - double to convert

report

public void report()
Print a report at the end of execution

Specified by:
report in interface Reportable

getOrCreateCounterIndexForString

public int getOrCreateCounterIndexForString(String str)
For a given string, return the number of the counter associated with this string. If this string doesn't already have a counter, reserve one.

Parameters:
str - The string for which you want the counter number
Returns:
The counter number for this string

getCounterIndexForString

public int getCounterIndexForString(String str)
For a given string, return the number of the counter associated with this string. Ideally this number would be completely hidden from the outside world, but for efficiency it is made public.

Parameters:
str - The string for which you want the counter number
Returns:
The counter number for this string, or -1 if the string has no counter associated with it.

reset

public void reset()
Description copied from interface: Reportable
reset (clear) data set being gathered

Specified by:
reset in interface Reportable