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

java.lang.Object
  extended by de.uka.ipd.sdq.ByCounter.execution.CountingResult
All Implemented Interfaces:
IFullCountingResult, ISimpleCountingResult, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<IFullCountingResult>

public final class CountingResult
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, IFullCountingResult, java.lang.Comparable<IFullCountingResult>

Class that holds the results of an (instrumented) method run. TODO test serialisation? test O/R-mapper? test XML serialisation? TODO in the long term, "section counts" should accept entire method as sections, and method call counts as well as opcodeCounts should become redundant TODO all setter method should return the old value of the set/overwritten variable

Since:
0.1
Version:
1.2
Author:
Martin Krogmann, Michael Kuperberg
See Also:
Serialized Form

Field Summary
 long forcedInlining_earliestStartOfInlinedMethod
          If this counting result describes "forced inlining", this field describes the earliest start of any of the inlined methods.
static int MAX_OPCODE
          The highest possible number of a Java bytecode opcode.
 
Fields inherited from interface de.uka.ipd.sdq.ByCounter.execution.ISimpleCountingResult
NO_COUNT_AVAILABLE
 
Constructor Summary
CountingResult(java.lang.String qualifyingMethodName, long methodInvocationBeginning, long methodReportingTime, long[] opcodeCounts, java.util.SortedMap<java.lang.String,java.lang.Long> methodCallCounts)
           
CountingResult(java.util.UUID requestID, java.util.UUID ownID, java.util.UUID callerID, java.lang.String ID, java.lang.String qualifyingMethodName, int fileType, long inputCharacterisation, long outputCharacterisation, long methodInvocationBeginning, long methodReportingTime, long[] opcodeCounts, java.util.SortedMap<java.lang.String,java.lang.Long> methodCallCounts, long[] arrayCreationCounts, int[] arrayCreationDimensions, java.lang.String[] arrayCreationTypeInfo)
          This constructor passes the arguments to the corresponding fields; the five fields that do not appear (this.characterisations, this.characterisationTitles, this.characterisationTypes and this.totalCountExclInvokes / this.totalCountInclInvokes) are initialised to empty collections (the first three) or set to 0 (the last two).
 
Method Summary
 void add_methodsInstructionsOnly(CountingResult toBeAdded)
          Adds the counts of this CountingResult instance to the counting results of the CountingResult instance given as parameter
 void add(CountingResult toBeAdded)
          Adds the counts of this CountingResult instance to the counting results of the CountingResult instance given as parameter
static CountingResult add(CountingResult left, CountingResult right)
          The returned CountingResult is completely different from the summands w.r.t. the method name, etc.
 void addCharacterisation(java.lang.String characterisationTitle, java.lang.Integer characterisationType, java.lang.Object characterisationValue)
          TODO document
static CountingResult addMethodsAndInstructionsOnly(CountingResult left, CountingResult right)
          The returned CountingResult is completely different from the summands w.r.t. the method name, etc.
 CountingResult clone()
           
 int compareTo(IFullCountingResult o)
          Compares getMethodInvocationBeginning().
 long[] getArrayCreationCounts()
          TODO
 int[] getArrayCreationDimensions()
          TODO
 java.lang.String[] getArrayCreationTypeInfo()
          TODO
 java.util.UUID getCallerID()
           
 java.util.List<java.lang.Object> getCharacterisations()
          TODO
 java.util.List<java.lang.String> getCharacterisationTitles()
          TODO
 java.util.List<java.lang.Integer> getCharacterisationTypes()
          TODO
 int getFileType()
          (non-Javadoc)
 long getForcedInlining_earliestStartOfInlinedMethod()
           
 java.lang.String getID()
           
 int getIndexOfRangeBlock()
           
 long getInputCharacterisation()
          (non-Javadoc)
 java.util.SortedMap<java.lang.String,java.lang.Long> getMethodCallCounts()
          Simple getter for method call counts.
 java.lang.Long getMethodCount(java.lang.String methodName)
          (non-Javadoc)
 java.lang.Long getMethodCountByString(java.lang.String methodName)
          (non-Javadoc)
 long getMethodInvocationBeginning()
          (non-Javadoc)
 long getMethodReportingTime()
          (non-Javadoc)
 long[] getNewArrayCounts()
          Simple getter
 int[] getNewArrayDim()
          Simple getter for the dimension of the new array if applicable; -1 else.
 java.lang.String[] getNewArrayTypes()
          Simple getter for the types of the new arrays.
 java.lang.Long getOpcodeCount(int opcode)
          (non-Javadoc)
 java.lang.Long getOpcodeCount(java.lang.String opcode)
          (non-Javadoc)
 java.lang.Long getOpcodeCountByInteger(int opcode)
          (non-Javadoc)
 java.lang.Long getOpcodeCountByString(java.lang.String opcode)
          (non-Javadoc)
 long[] getOpcodeCounts()
          (non-Javadoc)
 long getOutputCharacterisation()
          (non-Javadoc)
 java.util.UUID getOwnID()
           
 java.lang.String getQualifyingMethodName()
          (non-Javadoc)
 java.util.UUID getRequestID()
           
 int getSPECjvm2008_compress_fileType()
           
 java.lang.Long getTotalCount(boolean includeInvokeOpcodes)
          (non-Javadoc)
 java.lang.Long getTotalCountExclInvokes()
           
 java.lang.Long getTotalCountInclInvokes()
           
 boolean isInvariantMethodsAreInlined()
           
 boolean isTotalCountsAlreadyComputed()
           
 java.lang.String logResult(boolean printZeros, boolean vertically)
          Print a log message that reports the result, listing all counts and data that was collected.
 java.lang.String logResult(boolean printZeros, boolean vertically, java.util.logging.Level loggingLevel)
          Print a log message that reports the result, listing all counts and data that was collected.
static void main(java.lang.String[] args)
           
 java.lang.Long methodCountSum()
          Returns the total number of method invocations
 java.util.SortedMap<java.lang.String,java.lang.Long> overwriteMethodCallCounts(java.util.SortedMap<java.lang.String,java.lang.Long> methodCounts)
          Does not perform any plausibility checks
 long[] overwriteOpcodeCounts(long[] newOpcodeCounts)
          Does not perform any plausibility checks
 void resetMethodAndInstructionCounts()
          Does not affect parametric counts, etc.
 java.util.UUID setCallerID(java.util.UUID callerID)
           
 java.util.List<java.lang.Object> setCharacterisations(java.util.List<java.lang.Object> characterisations)
           
 java.util.List<java.lang.String> setCharacterisationTitles(java.util.List<java.lang.String> characterisationTitles)
           
 void setCharacterisationTypes(java.util.List<java.lang.Integer> characterisationTypes)
           
 void setFileType(int fileType)
           
 void setID(java.lang.String newID)
           
 void setIndexOfRangeBlock(int indexOfRangeBlock)
           
 void setInputCharacterisation(long inputCharacterisation)
           
 void setInvariantMethodsAreInlined(boolean invariantMethodsAreInlined)
          Flag indicating whether called methods are inlined (already part of bytecode counts)
 void setMethodInvocationBeginning(long methodInvocationBeginning)
           
 void setMethodReportingTime(long methodReportingTime)
          TODO consider adding a logger to CountingResult;
 void setOpcodeCount(int opcode, java.lang.Long count)
          (non-Javadoc)
 void setOutputCharacterisation(long outputCharacterisation)
           
 void setOwnID(java.util.UUID ownID)
           
 void setRequestID(java.util.UUID requestID)
           
 void setTotalCountExclInvokes(java.lang.Long totalCountExclInvokes)
           
 void setTotalCountInclInvokes(java.lang.Long totalCountInclInvokes)
           
 boolean shallowEquals(CountingResult vr)
          TODO replace return type to indicate precise location of difference (using the sum 1+2+4+8+16+etc.)
 java.lang.String toString()
          (non-Javadoc)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_OPCODE

public static final int MAX_OPCODE
The highest possible number of a Java bytecode opcode.


forcedInlining_earliestStartOfInlinedMethod

public long forcedInlining_earliestStartOfInlinedMethod
If this counting result describes "forced inlining", this field describes the earliest start of any of the inlined methods. Note that forced inlining may start *after* this value, since the reporting of the (forced-inlined) method can have happened *after* forced inlining was switched on.

Constructor Detail

CountingResult

public CountingResult(java.lang.String qualifyingMethodName,
                      long methodInvocationBeginning,
                      long methodReportingTime,
                      long[] opcodeCounts,
                      java.util.SortedMap<java.lang.String,java.lang.Long> methodCallCounts)

CountingResult

public CountingResult(java.util.UUID requestID,
                      java.util.UUID ownID,
                      java.util.UUID callerID,
                      java.lang.String ID,
                      java.lang.String qualifyingMethodName,
                      int fileType,
                      long inputCharacterisation,
                      long outputCharacterisation,
                      long methodInvocationBeginning,
                      long methodReportingTime,
                      long[] opcodeCounts,
                      java.util.SortedMap<java.lang.String,java.lang.Long> methodCallCounts,
                      long[] arrayCreationCounts,
                      int[] arrayCreationDimensions,
                      java.lang.String[] arrayCreationTypeInfo)
This constructor passes the arguments to the corresponding fields; the five fields that do not appear (this.characterisations, this.characterisationTitles, this.characterisationTypes and this.totalCountExclInvokes / this.totalCountInclInvokes) are initialised to empty collections (the first three) or set to 0 (the last two).

Parameters:
requestID -
ownID -
callerID -
ID -
qualifyingMethodName -
fileType -
inputCharacterisation -
outputCharacterisation -
methodInvocationBeginning -
methodReportingTime -
opcodeCounts -
methodCallCounts -
arrayCreationCounts -
arrayCreationDimensions -
arrayCreationTypeInfo -
Method Detail

add

public static CountingResult add(CountingResult left,
                                 CountingResult right)
The returned CountingResult is completely different from the summands w.r.t. the method name, etc. Hence, it is not initialised and only holds the sum of the two added CountingResults. Calling this method is quite expensive.

Parameters:
left - the first summand
right - the second summand
Returns:
an instance of CountingResult where only counts are initialised

addMethodsAndInstructionsOnly

public static CountingResult addMethodsAndInstructionsOnly(CountingResult left,
                                                           CountingResult right)
The returned CountingResult is completely different from the summands w.r.t. the method name, etc. Hence, it is not initialised and only holds the sum of the two added CountingResults. Calling this method is quite expensive.

Parameters:
left - the first summand
right - the second summand
Returns:
an instance of CountingResult where only counts are initialised

main

public static void main(java.lang.String[] args)

add

public void add(CountingResult toBeAdded)
Adds the counts of this CountingResult instance to the counting results of the CountingResult instance given as parameter

Parameters:
toBeAdded - CountingResult instance whose counts are to be added

add_methodsInstructionsOnly

public void add_methodsInstructionsOnly(CountingResult toBeAdded)
Adds the counts of this CountingResult instance to the counting results of the CountingResult instance given as parameter

Parameters:
toBeAdded - CountingResult instance whose counts are to be added

addCharacterisation

public void addCharacterisation(java.lang.String characterisationTitle,
                                java.lang.Integer characterisationType,
                                java.lang.Object characterisationValue)
TODO document

Parameters:
characterisationTitle -
characterisationType -
characterisationValue -

clone

public CountingResult clone()
Overrides:
clone in class java.lang.Object

getArrayCreationCounts

public long[] getArrayCreationCounts()
TODO

Returns:
TODO

getArrayCreationDimensions

public int[] getArrayCreationDimensions()
TODO

Returns:
TODO

getArrayCreationTypeInfo

public java.lang.String[] getArrayCreationTypeInfo()
TODO

Returns:
TODO

getCallerID

public java.util.UUID getCallerID()
Returns:
the callerID

getCharacterisations

public java.util.List<java.lang.Object> getCharacterisations()
TODO

Returns:
TODO

getCharacterisationTitles

public java.util.List<java.lang.String> getCharacterisationTitles()
TODO

Returns:
TODO

getCharacterisationTypes

public java.util.List<java.lang.Integer> getCharacterisationTypes()
TODO

Returns:
TODO

getFileType

public int getFileType()
(non-Javadoc)

Specified by:
getFileType in interface ISimpleCountingResult
Returns:
The input file type.
See Also:
ISimpleCountingResult.getFileType()

getID

public java.lang.String getID()
Returns:
the ID

getInputCharacterisation

public long getInputCharacterisation()
(non-Javadoc)

Specified by:
getInputCharacterisation in interface ISimpleCountingResult
Returns:
For example, for SPECjvm2008.Compress, this is the size of the input file (in bytes)
See Also:
ISimpleCountingResult.getInputCharacterisation()

getMethodCallCounts

public java.util.SortedMap<java.lang.String,java.lang.Long> getMethodCallCounts()
Simple getter for method call counts.

Specified by:
getMethodCallCounts in interface IFullCountingResult
Returns:
A HashMap were the method name is mapped to the number of calls of that method.

getMethodCount

public java.lang.Long getMethodCount(java.lang.String methodName)
(non-Javadoc)

Specified by:
getMethodCount in interface ISimpleCountingResult
Returns:
Method execution count
See Also:
ISimpleCountingResult.getMethodCount(java.lang.String)

getMethodCountByString

public java.lang.Long getMethodCountByString(java.lang.String methodName)
(non-Javadoc)

Specified by:
getMethodCountByString in interface IFullCountingResult
Returns:
Method execution count.
See Also:
IFullCountingResult.getMethodCountByString(java.lang.String)

getMethodInvocationBeginning

public long getMethodInvocationBeginning()
(non-Javadoc)

Specified by:
getMethodInvocationBeginning in interface IFullCountingResult
Returns:
Beginning time of method invocation.
See Also:
IFullCountingResult.getMethodInvocationBeginning()

getMethodReportingTime

public long getMethodReportingTime()
(non-Javadoc)

Specified by:
getMethodReportingTime in interface IFullCountingResult
Returns:
Time of result reporting for the method.
See Also:
IFullCountingResult.getMethodReportingTime()

getNewArrayCounts

public long[] getNewArrayCounts()
Simple getter

Returns:
Counts for array constructions when recording was enabled; null else.

getNewArrayDim

public int[] getNewArrayDim()
Simple getter for the dimension of the new array if applicable; -1 else.

Returns:
The array dimension when recording was enabled as descriped above. Null else.

getNewArrayTypes

public java.lang.String[] getNewArrayTypes()
Simple getter for the types of the new arrays.

Returns:
The array type when recording was enabled. Null else.

getOpcodeCount

public java.lang.Long getOpcodeCount(int opcode)
(non-Javadoc)

Specified by:
getOpcodeCount in interface ISimpleCountingResult
Returns:
Opcode execution count
See Also:
ISimpleCountingResult.getOpcodeCount(int)

getOpcodeCount

public java.lang.Long getOpcodeCount(java.lang.String opcode)
(non-Javadoc)

Specified by:
getOpcodeCount in interface ISimpleCountingResult
Returns:
Opcode execution count
See Also:
ISimpleCountingResult.getOpcodeCount(java.lang.String)

getOpcodeCountByInteger

public java.lang.Long getOpcodeCountByInteger(int opcode)
(non-Javadoc)

Specified by:
getOpcodeCountByInteger in interface IFullCountingResult
Returns:
Opcode execution count
See Also:
IFullCountingResult.getOpcodeCountByInteger(int)

getOpcodeCountByString

public java.lang.Long getOpcodeCountByString(java.lang.String opcode)
(non-Javadoc)

Specified by:
getOpcodeCountByString in interface IFullCountingResult
Returns:
Opcode execution count
See Also:
IFullCountingResult.getOpcodeCountByString(java.lang.String)

getOpcodeCounts

public long[] getOpcodeCounts()
(non-Javadoc)

Specified by:
getOpcodeCounts in interface IFullCountingResult
Returns:
The counts.
See Also:
IFullCountingResult.getOpcodeCounts()

getOutputCharacterisation

public long getOutputCharacterisation()
(non-Javadoc)

Specified by:
getOutputCharacterisation in interface ISimpleCountingResult
Returns:
For example, for SPECjvm2008.Compress, this is the size of the buffer which holds the compressed data of the input file.
See Also:
ISimpleCountingResult.getOutputCharacterisation()

getOwnID

public java.util.UUID getOwnID()
Returns:
the ownID

getQualifyingMethodName

public java.lang.String getQualifyingMethodName()
(non-Javadoc)

Specified by:
getQualifyingMethodName in interface IFullCountingResult
Returns:
the qualifyingMethodName
See Also:
IFullCountingResult.getQualifyingMethodName()

getRequestID

public java.util.UUID getRequestID()
Specified by:
getRequestID in interface IFullCountingResult
Returns:
the requestID

getTotalCount

public java.lang.Long getTotalCount(boolean includeInvokeOpcodes)
(non-Javadoc)

Specified by:
getTotalCount in interface ISimpleCountingResult
Returns:
Total number of executed opcodes.
See Also:
ISimpleCountingResult.getTotalCount(boolean)

getTotalCountExclInvokes

public java.lang.Long getTotalCountExclInvokes()
Returns:
totalCountExclInvokes

getTotalCountInclInvokes

public java.lang.Long getTotalCountInclInvokes()
Returns:
totalCountInclInvokes

isInvariantMethodsAreInlined

public boolean isInvariantMethodsAreInlined()
Returns:
Value of the flag indicating whether called methods are inlined (already part of bytecode counts)

methodCountSum

public java.lang.Long methodCountSum()
Returns the total number of method invocations

Returns:
the total number of method invocations

overwriteMethodCallCounts

public java.util.SortedMap<java.lang.String,java.lang.Long> overwriteMethodCallCounts(java.util.SortedMap<java.lang.String,java.lang.Long> methodCounts)
Does not perform any plausibility checks

Parameters:
methodCounts -
Returns:
old method counts

overwriteOpcodeCounts

public long[] overwriteOpcodeCounts(long[] newOpcodeCounts)
Does not perform any plausibility checks

Parameters:
newOpcodeCounts -
Returns:
old opcode counts (before overwriting)

resetMethodAndInstructionCounts

public void resetMethodAndInstructionCounts()
Does not affect parametric counts, etc.


setCallerID

public java.util.UUID setCallerID(java.util.UUID callerID)
Parameters:
callerID - the callerID to set
Returns:
The previously set caller id.

setCharacterisations

public java.util.List<java.lang.Object> setCharacterisations(java.util.List<java.lang.Object> characterisations)
Parameters:
characterisations -
Returns:
The previously set characterisations.

setCharacterisationTitles

public java.util.List<java.lang.String> setCharacterisationTitles(java.util.List<java.lang.String> characterisationTitles)
Parameters:
characterisationTitles -
Returns:
The previously set characterisationTitles.

setCharacterisationTypes

public void setCharacterisationTypes(java.util.List<java.lang.Integer> characterisationTypes)
Parameters:
characterisationTypes -

setFileType

public void setFileType(int fileType)
Parameters:
fileType -

setID

public void setID(java.lang.String newID)
Parameters:
newID -

setInputCharacterisation

public void setInputCharacterisation(long inputCharacterisation)

setInvariantMethodsAreInlined

public void setInvariantMethodsAreInlined(boolean invariantMethodsAreInlined)
Flag indicating whether called methods are inlined (already part of bytecode counts)

Parameters:
invariantMethodsAreInlined -

setMethodInvocationBeginning

public void setMethodInvocationBeginning(long methodInvocationBeginning)
Parameters:
methodInvocationBeginning -

setMethodReportingTime

public void setMethodReportingTime(long methodReportingTime)
TODO consider adding a logger to CountingResult;

Parameters:
methodReportingTime -

setOpcodeCount

public void setOpcodeCount(int opcode,
                           java.lang.Long count)
(non-Javadoc)

Specified by:
setOpcodeCount in interface ISimpleCountingResult
See Also:
ISimpleCountingResult.setOpcodeCount(int, java.lang.Long)

setOutputCharacterisation

public void setOutputCharacterisation(long outputCharacterisation)

setOwnID

public void setOwnID(java.util.UUID ownID)
Parameters:
ownID - the ownID to set

setRequestID

public void setRequestID(java.util.UUID requestID)
Parameters:
requestID - the requestID to set

setTotalCountExclInvokes

public void setTotalCountExclInvokes(java.lang.Long totalCountExclInvokes)

setTotalCountInclInvokes

public void setTotalCountInclInvokes(java.lang.Long totalCountInclInvokes)

shallowEquals

public boolean shallowEquals(CountingResult vr)
TODO replace return type to indicate precise location of difference (using the sum 1+2+4+8+16+etc.)

Parameters:
vr -
Returns:
True, if counting results equal (shallow).

toString

public java.lang.String toString()
(non-Javadoc)

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

setIndexOfRangeBlock

public void setIndexOfRangeBlock(int indexOfRangeBlock)
Parameters:
indexOfRangeBlock - the indexOfRangeBlock to set

getIndexOfRangeBlock

public int getIndexOfRangeBlock()
Returns:
If range blocks were used, this is the index of the range block in the method (getQualifyingMethodName()). Otherwise this is -1;

getSPECjvm2008_compress_fileType

public int getSPECjvm2008_compress_fileType()

getForcedInlining_earliestStartOfInlinedMethod

public long getForcedInlining_earliestStartOfInlinedMethod()

isTotalCountsAlreadyComputed

public boolean isTotalCountsAlreadyComputed()

logResult

public java.lang.String logResult(boolean printZeros,
                                  boolean vertically)
Print a log message that reports the result, listing all counts and data that was collected.

Parameters:
printZeros - When true, opcodes with an execution count of 0 are printed.
vertically - When true, print as one opcode/method count per line.
Returns:
The string with the logged message.

logResult

public java.lang.String logResult(boolean printZeros,
                                  boolean vertically,
                                  java.util.logging.Level loggingLevel)
Print a log message that reports the result, listing all counts and data that was collected.

Parameters:
printZeros - When true, opcodes with an execution count of 0 are printed.
vertically - When true, print as one opcode/method count per line.
loggingLevel - Level used to log the message.
Returns:
The string with the logged message.

compareTo

public int compareTo(IFullCountingResult o)
Compares getMethodInvocationBeginning().

Specified by:
compareTo in interface java.lang.Comparable<IFullCountingResult>