de.uka.ipd.sdq.ByCounter.execution
Class CountingResultCollector

java.lang.Object
  extended by java.util.Observable
      extended by de.uka.ipd.sdq.ByCounter.execution.CountingResultCollector

public final class CountingResultCollector
extends java.util.Observable

Class used to collect statistics about an instrumented method.

This class is observable (Observable.addObserver(java.util.Observer)) and can provide online updates on the collection of results. Updates consist of update objects with types implementing the CountingResultCollector.ObservedEvent interface. The following update types are currently available:

TODO implement an "adaptation-oriented inlining", where after a certain (threshold) number of invocations, a method is inlined (callees independently, too)

Since:
0.1
Version:
1.2
Author:
Martin Krogmann, Michael Kuperberg

Nested Class Summary
 class CountingResultCollector.ObservedCompleteMethodExecutionUpdate
          This class is used to update observers registered to CountingResultCollector when a complete method has been executed, i.e. reached a return statement or a throw statement.
static interface CountingResultCollector.ObservedEvent
          This is the common interface of CountingResultCollector events that can be observed.
 class CountingResultCollector.ObservedSectionExecutionUpdate
          This class is used to update observers registered to CountingResultCollector when a section has been executed.
 
Field Summary
 BlockDefinitionContext blockContext
          Basic block and range block definitions.
static CountingResultCollectorMode MODE_DEFAULT
          Default value for getMode().
static java.lang.String SIGNATURE_protocolCount
          The bytecode parameter descriptor for protocolCount(ProtocolCountStructure).
 
Method Summary
 void clearResults()
          Clear all results in the internal list.
 java.util.List<ICountingResultWriter> getAllResultWriters()
          Gets all result writers registered to the collector.
 CountingResultIndexing getCountingResultIndexing()
           
static CountingResultCollector getInstance()
          Public singleton accessor.
 MethodExecutionRecord getLastMethodExecutionDetails()
          The settings used for the last execution relevant to the CountingResultCollector.
 CountingResultCollectorMode getMode()
           
 boolean getMonitorShouldStop()
          Deprecated. because only GUI-used but the GUI is outdated
 void monitorShouldStop()
          Deprecated. because only GUI-used but the GUI is outdated
 void protocolCount(ProtocolCountStructure result)
          An instrumented class calls this method to report the instruction and method call counts.
 void registerWriter(ICountingResultWriter resultWriter)
          Adds an additional result writer used in CountingResult.logResult(boolean, boolean, Level).
 java.util.SortedSet<CountingResult> retrieveAllCountingResults()
          Get all results the CountingResultCollector holds.
 void setLastMethodExecutionDetails(MethodExecutionRecord lastMethodExecutionDetails)
          This is called by BytecodeCounter when an execute method is executed to provide the details of the execution to CountingResultCollector.
 void setMonitorShouldStop(boolean monitorShouldStop)
          Deprecated. because only GUI-used but the GUI is outdated
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_DEFAULT

public static final CountingResultCollectorMode MODE_DEFAULT
Default value for getMode().


SIGNATURE_protocolCount

public static final java.lang.String SIGNATURE_protocolCount
The bytecode parameter descriptor for protocolCount(ProtocolCountStructure).

See Also:
Constant Field Values

blockContext

public BlockDefinitionContext blockContext
Basic block and range block definitions.

Method Detail

getInstance

public static CountingResultCollector getInstance()
Public singleton accessor. Use this to get a reference to the singleton instance.

Returns:
The singleton instance of CountingResultCollector.

clearResults

public void clearResults()
Clear all results in the internal list.


getAllResultWriters

public java.util.List<ICountingResultWriter> getAllResultWriters()
Gets all result writers registered to the collector.

Returns:
A list of ICountingResultWriters.

getMode

public CountingResultCollectorMode getMode()
See Also:
BytecodeCounter.setExecutionSettings(ExecutionSettings)

getMonitorShouldStop

public boolean getMonitorShouldStop()
Deprecated. because only GUI-used but the GUI is outdated


monitorShouldStop

public void monitorShouldStop()
Deprecated. because only GUI-used but the GUI is outdated


protocolCount

public void protocolCount(ProtocolCountStructure result)
An instrumented class calls this method to report the instruction and method call counts. TODO: how far is "synchronized" problematic in multi-threading?

Parameters:
result - The result reported by an instrumented method.

registerWriter

public void registerWriter(ICountingResultWriter resultWriter)
Adds an additional result writer used in CountingResult.logResult(boolean, boolean, Level).

Parameters:
resultWriter - ICountingResultWriter used when logging result.

retrieveAllCountingResults

public java.util.SortedSet<CountingResult> retrieveAllCountingResults()
Get all results the CountingResultCollector holds. This does not clear the CountingResultCollector list. You have to explicitly call clearResults() if that is your intention.

Returns:
A Result list.

setMonitorShouldStop

public void setMonitorShouldStop(boolean monitorShouldStop)
Deprecated. because only GUI-used but the GUI is outdated

Parameters:
monitorShouldStop -

setLastMethodExecutionDetails

public void setLastMethodExecutionDetails(MethodExecutionRecord lastMethodExecutionDetails)
This is called by BytecodeCounter when an execute method is executed to provide the details of the execution to CountingResultCollector.

Do not call; instead use BytecodeCounter.setExecutionSettings(ExecutionSettings).

Parameters:
lastMethodExecutionDetails - Method execution details.

getLastMethodExecutionDetails

public MethodExecutionRecord getLastMethodExecutionDetails()
The settings used for the last execution relevant to the CountingResultCollector.

Do not call to change these settings. Instead, use BytecodeCounter.setExecutionSettings(ExecutionSettings).

Returns:
the lastMethodExecutionDetails
See Also:
setLastMethodExecutionDetails(MethodExecutionRecord)

getCountingResultIndexing

public CountingResultIndexing getCountingResultIndexing()
Returns:
Indexing infrastructure for counting results.