com.sun.faban.driver.util.timermeter
Class TimerMeter

java.lang.Object
  extended by com.sun.faban.driver.util.timermeter.TimerMeter
All Implemented Interfaces:
Runnable

public class TimerMeter
extends Object
implements Runnable

The TimerMeter code in large is a modification from Michael Kuperberg's TimerMeter work. We thank him for this work.

Michael Kuperberg (mkuper@ipd.uka.de),
Chair for Software Design and Quality (SDQ),
Institute for Program Structures and Data Organisation (IPD),
Faculty of Informatics, University of Karlsruhe, Germany
http://sdq.ipd.uka.de


Field Summary
protected  int currentUpperLoopSizeBound
          not private because needed in obtainMeasurementsUsingDirectInvocation
 int increased
          Global variable used by the core algorithm.
protected  int iterationIncreaseStepWidth
          See class description.
protected  long methodReturnAtMeasurementFinish
          Protected because it must be set and read in subclasses' that override the obtainMeasurementsUsingDirectInvocation method
protected  long methodReturnAtMeasurementStart
          protected because it must be set and read in subclasses' that override the obtainMeasurementsUsingDirectInvocation method
protected  int numberOfIterationIncreaseSteps
          Actual maximum number of for loop iterations that are executed between two nanoTime invocations (cf.
protected  int numberOfMeasurements
          See class description.
protected  int numberOfProcessRepetitions
          Number of times the entire process is repeated.
protected  int numberOfWarmupTimerInvocations
          See class description.
protected static long publicDummy
          This dummy variable is used for warmup; it is intentionally global because of JIT / dead code elimination prevention.
protected  String timerMethodName
          TODO document assumption: parameterless and no class/package name! --> no parentheses: (){}[]<> and no "."s and ";" s
protected  String warningOnNegativeDiff
          Warning message displayed when the timer value difference of two consecutive is negative.
 
Constructor Summary
TimerMeter(int warmupLoops, int repeats, int measurements, int increaseWidth, int increaseAfter, int clusterThreshold)
           
 
Method Summary
 TimerCharacterisation computeTimerCharacterization(long[][] timerMeterMeasurements, boolean logValues)
          TODO engineer for performance: use one-dimensional array and work with offsets?
static void main(String[] args)
          Test main method.
protected  long[][] obtainMeasurementsUsingDirectInvocation()
          THIS METHOD MUST BE OVERRIDDEN IN SUBCLASSES.
 String printTimerCharacterization()
           
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

publicDummy

protected static long publicDummy
This dummy variable is used for warmup; it is intentionally global because of JIT / dead code elimination prevention.


currentUpperLoopSizeBound

protected int currentUpperLoopSizeBound
not private because needed in obtainMeasurementsUsingDirectInvocation


increased

public int increased
Global variable used by the core algorithm.


iterationIncreaseStepWidth

protected int iterationIncreaseStepWidth
See class description.


methodReturnAtMeasurementFinish

protected long methodReturnAtMeasurementFinish
Protected because it must be set and read in subclasses' that override the obtainMeasurementsUsingDirectInvocation method


methodReturnAtMeasurementStart

protected long methodReturnAtMeasurementStart
protected because it must be set and read in subclasses' that override the obtainMeasurementsUsingDirectInvocation method


numberOfIterationIncreaseSteps

protected int numberOfIterationIncreaseSteps
Actual maximum number of for loop iterations that are executed between two nanoTime invocations (cf. class description)


numberOfMeasurements

protected int numberOfMeasurements
See class description.


numberOfProcessRepetitions

protected int numberOfProcessRepetitions
Number of times the entire process is repeated.


numberOfWarmupTimerInvocations

protected int numberOfWarmupTimerInvocations
See class description.


timerMethodName

protected String timerMethodName
TODO document assumption: parameterless and no class/package name! --> no parentheses: (){}[]<> and no "."s and ";" s


warningOnNegativeDiff

protected final String warningOnNegativeDiff
Warning message displayed when the timer value difference of two consecutive is negative.

Constructor Detail

TimerMeter

public TimerMeter(int warmupLoops,
                  int repeats,
                  int measurements,
                  int increaseWidth,
                  int increaseAfter,
                  int clusterThreshold)
Method Detail

main

public static void main(String[] args)
Test main method.

Parameters:
args - Command line arguments, unused.

computeTimerCharacterization

public final TimerCharacterisation computeTimerCharacterization(long[][] timerMeterMeasurements,
                                                                boolean logValues)
TODO engineer for performance: use one-dimensional array and work with offsets?

Parameters:
timerMeterMeasurements - The measurement results
logValues - Whether to log values or not
Returns:
The timer characterization

obtainMeasurementsUsingDirectInvocation

protected long[][] obtainMeasurementsUsingDirectInvocation()
THIS METHOD MUST BE OVERRIDDEN IN SUBCLASSES. Implementation is provided here as an example. Use it and replace the nanoTime. After "warming up" the timer method numberOfWarmupTimerInvocations times, this method measures the duration of a 'for' loop. The measurement is repeated numberOfMeasurements times for each loop iteration number from 0 to numberOfIterationIncreaseSteps.

Returns:
List of measurements

printTimerCharacterization

public String printTimerCharacterization()

run

public void run()
Specified by:
run in interface Runnable