com.sun.faban.driver.engine
Class Metrics

java.lang.Object
  extended by com.sun.faban.driver.engine.Metrics
All Implemented Interfaces:
PairwiseAggregator.Aggregable<Metrics>, Serializable, Cloneable

public class Metrics
extends Object
implements Serializable, Cloneable, PairwiseAggregator.Aggregable<Metrics>

Generic statistics collection and reporting facility. For simple agents without any additional statistics, this class can be used right away. This class should also be extended to collect all additional statistics.

Author:
Akara Sucharitakul
See Also:
Serialized Form

Field Summary
static int COARSE_RESPBUCKETS
          The number and percentage of coarse response time buckets.
protected  long coarseRespBucketSize
          Size of the coarse response time bucket.
protected  long coarseRespHistMax
          Max coarse response time.
protected  long cycleSum
          Sum of cycle time (not think time) for little's law verification.
static int DELAYBUCKETS
          Number of delay time buckets in histogram.
protected  long delayBucketSize
          Size of each delay time bucket, in ns.
protected  int[] delayCntStdy
          Number of transactions the delay time was successfuly recorded.
protected  int[][] delayHist
          Histogram of actual delay times.
protected  long[] delayMax
          Maximum delay times.
protected  long[] delayMin
          Minimum delay times.
protected  long[] delaySum
          Sum of delay (cycle/think) times.
protected  String driverName
          Name of the driver.
protected  int driverType
          Type id of the driver.
protected  long endTime
          End time as ms offset from start time.
protected  long endTimeNanos
          End time as nanosec time.
protected  int[] errCntStdy
          Number of failed transactions during steady state.
protected  int[] errCntTotal
          Number of failed transactions total.
static int FINE_RESPBUCKETS
          The number of fine response time buckets.
protected  long fineRespBucketSize
          Size of the fine response time bucket.
protected  long fineRespHistMax
          Max fine response time.
protected  int graphBuckets
          Number of graph buckets.
protected  long graphBucketSize
          Size of each graph bucket, in ns.
protected  double[] hiRespSumStdy
          Sum of high response times that fall into the overflow bucket.
protected  String host
          Originating host name.
protected  double metric
          The final resulting metric.
protected  LinkedHashMap<String,CustomMetrics> metricAttachments
          The attached custom metrics.
static int RESPBUCKET_SIZE_RATIO
          The bucket size ratio between coarse and fine response time buckets.
static int RESPBUCKETS
          The total number of response time buckets.
protected  long[][] respGraph
          Graph of accumulated response times over the course of the run.
protected  int[][] respHist
          Response time histogram.
protected  long[] respMax
          Max.
protected  double[] respSumStdy
          Sum of response times during steady state.
protected  double[] respSumTotal
          Sum of response times total.
protected  long startTime
          Start time as absolute time, in ms.
protected  int stdyState
          Run steady state, in milliseconds.
protected  double[] sumSquaresStdy
          Sum of squares of the deviation during steady state.
protected  double[] sumSquaresTotal
          Overall sum of squares of the deviation.
protected  LinkedHashMap<String,CustomTableMetrics> tableAttachments
          The attached custom table metrics.
protected  int[][] targetedDelayHist
          Histogram of selected delay times.
protected  long[] targetedDelaySum
          Targeted delay times.
protected  AgentThread thread
          Reference to the thread associated with this metrics.
protected  int[][] thruputGraph
          The thruput graph.
protected  int[] txCntStdy
          Number of successful transactions during steady state.
protected  int[] txCntTotal
          Number of successful transactions total.
protected  String[] txNames
          List of operation names.
protected  int txTypes
          Number of operations in the driver.
 
Constructor Summary
Metrics(AgentThread agent)
          Constructs a Metrics object for this agent thread.
 
Method Summary
 void add(Metrics s)
          This method aggregates the stats with the stats of another thread.
 Object clone()
          Makes a deep copy of this metrics object.
 double getTps()
          Calculates the aggregate TPS from the current stats.
 void printDetail(StringBuilder b)
          Prints the detail results into the given buffer.
 boolean printSummary(StringBuilder buffer, BenchmarkDefinition benchDef)
          Prints the summary report for the statistics.
 void recordDelayTime()
          Records the delay (think/cycle) time.
 void recordError()
          Records the error count for an unsuccessful transaction.
 void recordTx()
          Updates the various stats for a successful transaction.
 String toString()
          Provides a string presentation of the current stats.
 void wrap()
          Wraps up the metric for serialization/transportation and/or further processing.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESPBUCKET_SIZE_RATIO

public static final int RESPBUCKET_SIZE_RATIO
The bucket size ratio between coarse and fine response time buckets.

See Also:
Constant Field Values

COARSE_RESPBUCKETS

public static final int COARSE_RESPBUCKETS
The number and percentage of coarse response time buckets.

See Also:
Constant Field Values

FINE_RESPBUCKETS

public static final int FINE_RESPBUCKETS
The number of fine response time buckets.

See Also:
Constant Field Values

RESPBUCKETS

public static final int RESPBUCKETS
The total number of response time buckets.

See Also:
Constant Field Values

DELAYBUCKETS

public static final int DELAYBUCKETS
Number of delay time buckets in histogram.

See Also:
Constant Field Values

fineRespBucketSize

protected long fineRespBucketSize
Size of the fine response time bucket.


coarseRespBucketSize

protected long coarseRespBucketSize
Size of the coarse response time bucket.


fineRespHistMax

protected long fineRespHistMax
Max fine response time.


coarseRespHistMax

protected long coarseRespHistMax
Max coarse response time.


delayBucketSize

protected long delayBucketSize
Size of each delay time bucket, in ns.


graphBucketSize

protected long graphBucketSize
Size of each graph bucket, in ns.


graphBuckets

protected int graphBuckets
Number of graph buckets.


txCntStdy

protected int[] txCntStdy
Number of successful transactions during steady state. This is used for final reporting and in-flight reporting of averages.


txCntTotal

protected int[] txCntTotal
Number of successful transactions total. This is used for in-flight reporting only.


errCntStdy

protected int[] errCntStdy
Number of failed transactions during steady state. This is used for final reporting and in-flight reporting of averages.


errCntTotal

protected int[] errCntTotal
Number of failed transactions total. This is used for in-flight reporting only.


delayCntStdy

protected int[] delayCntStdy
Number of transactions the delay time was successfuly recorded. Note that some transactions while failing may still have the delay time recorded. Transactions that do not have the delay time recorded are transactions that fail before the critical section.


respSumStdy

protected double[] respSumStdy
Sum of response times during steady state. This is used for final reporting and runtime reporting of averages.


respSumTotal

protected double[] respSumTotal
Sum of response times total. This is used for runtime reporting only.


hiRespSumStdy

protected double[] hiRespSumStdy
Sum of high response times that fall into the overflow bucket. This is used for calculating the representative value for the overflow bucket to establish a reasonable standard deviation.


sumSquaresStdy

protected double[] sumSquaresStdy
Sum of squares of the deviation during steady state.


sumSquaresTotal

protected double[] sumSquaresTotal
Overall sum of squares of the deviation.


respMax

protected long[] respMax
Max. response time.


delaySum

protected long[] delaySum
Sum of delay (cycle/think) times.


targetedDelaySum

protected long[] targetedDelaySum
Targeted delay times.


delayMax

protected long[] delayMax
Maximum delay times.


delayMin

protected long[] delayMin
Minimum delay times.


cycleSum

protected long cycleSum
Sum of cycle time (not think time) for little's law verification.


respHist

protected int[][] respHist
Response time histogram.


delayHist

protected int[][] delayHist
Histogram of actual delay times.


targetedDelayHist

protected int[][] targetedDelayHist
Histogram of selected delay times.


startTime

protected long startTime
Start time as absolute time, in ms.


endTime

protected long endTime
End time as ms offset from start time.


endTimeNanos

protected transient long endTimeNanos
End time as nanosec time.


thruputGraph

protected int[][] thruputGraph
The thruput graph. This is updated throughout the run, not only in steady state. The graph accumulates tx count during the run. The final results need to be divided by the graph bucket size.


respGraph

protected long[][] respGraph
Graph of accumulated response times over the course of the run. This data need to be divided by the accumulated tx count for the bucket to get the avg response time in that bucket.


metricAttachments

protected LinkedHashMap<String,CustomMetrics> metricAttachments
The attached custom metrics.


tableAttachments

protected LinkedHashMap<String,CustomTableMetrics> tableAttachments
The attached custom table metrics.


metric

protected double metric
The final resulting metric. This field is only populated after printing the summary report


host

protected String host
Originating host name.


driverType

protected int driverType
Type id of the driver.


driverName

protected String driverName
Name of the driver.


txTypes

protected int txTypes
Number of operations in the driver.


txNames

protected String[] txNames
List of operation names.


stdyState

protected int stdyState
Run steady state, in milliseconds.


thread

protected transient AgentThread thread
Reference to the thread associated with this metrics.

Constructor Detail

Metrics

public Metrics(AgentThread agent)
Constructs a Metrics object for this agent thread.

Parameters:
agent - The agent thread
Method Detail

recordTx

public void recordTx()
Updates the various stats for a successful transaction.


recordError

public void recordError()
Records the error count for an unsuccessful transaction.


recordDelayTime

public void recordDelayTime()
Records the delay (think/cycle) time. The delay time is recorded regardless of whether a transaction succeeds or fails.


wrap

public void wrap()
Wraps up the metric for serialization/transportation and/or further processing.


add

public void add(Metrics s)
This method aggregates the stats with the stats of another thread. It is called repeatedly, and the called passes it the stats of a different thread, each time

Specified by:
add in interface PairwiseAggregator.Aggregable<Metrics>
Parameters:
s - stats of next thread to be aggregated

clone

public Object clone()
Makes a deep copy of this metrics object.

Overrides:
clone in class Object
Returns:
The copy of this metrics object
See Also:
Object.clone()

getTps

public double getTps()
Calculates the aggregate TPS from the current stats.

Returns:
The current aggregate TPS

toString

public String toString()
Provides a string presentation of the current stats.

Overrides:
toString in class Object
Returns:
The string representing the statistics.

printSummary

public boolean printSummary(StringBuilder buffer,
                            BenchmarkDefinition benchDef)
Prints the summary report for the statistics. This will usually be called once the statistics have been accumulated.

Parameters:
buffer - The buffer for outputting the summary
benchDef - The benchmark definition
Returns:
true if this driver passed, false if not

printDetail

public void printDetail(StringBuilder b)
Prints the detail results into the given buffer.

Parameters:
b - The buffer