org.sape.carbon.services.perflog
Class BoundedBufferPerformanceLogger.TimingInfo

java.lang.Object
  |
  +--org.sape.carbon.services.perflog.BoundedBufferPerformanceLogger.TimingInfo
Enclosing class:
BoundedBufferPerformanceLogger

public static class BoundedBufferPerformanceLogger.TimingInfo
extends Object

This inner class supports the tracking of timings on a single tracked item. It stores the item to be tracked as well as a array-based bounded buffer. This buffer of configurable size stores the last n timings for use in determing rolling averages for the timings as well as standard deviation.

The provided minimum and maximum values are calculated for all timings regardless of whether they are within the bounded-buffer at a given point in time.


Field Summary
private  int capacity
          Holds the size of the timingArray.
private  boolean full
          Indicates if the timingArray is full.
private  int index
          Holds the current index for the new timing.
private  long max
          Holds the max time taken.
private  long min
          Holds the min time taken.
private  long[] timingArray
          Holds the timings for the method.
private  Object trackedObject
          Holds the object being tracked.
 
Constructor Summary
BoundedBufferPerformanceLogger.TimingInfo(Object trackedObject, int capacity)
          Creates a new timing info object for the specified tracked object of the specified size.
 
Method Summary
 void addTiming(long time)
          Adds a new timing into the statistics.
 double getAverage()
          Calculates the average time of the calls.
 long getMax()
          Returns the max time taken.
 long getMin()
          Returns the mininum time taken.
 double getStandardDeviation()
          Calcluate standard deviation in timings using Knuth's algorithm.
 Object getTrackedObject()
          Retrieves the object being tracked.
 int size()
          Returns the amount of timings stored in the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trackedObject

private Object trackedObject
Holds the object being tracked.


capacity

private int capacity
Holds the size of the timingArray.


full

private boolean full
Indicates if the timingArray is full.


timingArray

private long[] timingArray
Holds the timings for the method.


index

private int index
Holds the current index for the new timing. The index wraps around back to zero after reaching the capacity and replaces old values.


min

private long min
Holds the min time taken.


max

private long max
Holds the max time taken.

Constructor Detail

BoundedBufferPerformanceLogger.TimingInfo

public BoundedBufferPerformanceLogger.TimingInfo(Object trackedObject,
                                                 int capacity)
Creates a new timing info object for the specified tracked object of the specified size.

Parameters:
trackedObject - The object to be tracked.
capacity - the number of timings that will be tracked.
Method Detail

getTrackedObject

public Object getTrackedObject()
Retrieves the object being tracked.

Returns:
the object being tracked

addTiming

public void addTiming(long time)
Adds a new timing into the statistics.

Parameters:
time - the length of time of the method call

getMin

public long getMin()
Returns the mininum time taken.

Returns:
the min time taken

getMax

public long getMax()
Returns the max time taken.

Returns:
max time taken

size

public int size()
Returns the amount of timings stored in the object.

Returns:
amount of timings stored in the object

getStandardDeviation

public double getStandardDeviation()
Calcluate standard deviation in timings using Knuth's algorithm.

Returns:
standard deviation

getAverage

public double getAverage()
Calculates the average time of the calls.

Returns:
the average time of the calls.


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.