org.sape.carbon.services.perflog
Class BoundedBufferPerformanceLogger

java.lang.Object
  |
  +--org.sape.carbon.services.perflog.DefaultPerformanceLogger
        |
        +--org.sape.carbon.services.perflog.BoundedBufferPerformanceLogger
All Implemented Interfaces:
Configurable, FunctionalInterface, PerformanceLogger, ReportingPerformanceLogger

public class BoundedBufferPerformanceLogger
extends DefaultPerformanceLogger
implements ReportingPerformanceLogger, Configurable

This extension on the basic performance logger provides the additional capability to track timings over a period of time and get report on their minimums, maximum, averages and standard deviations. This implementation uses a rolling, array-based bounded buffer to store up to the last "n" timings.

Copyright 2003 Sapient

Since:
carbon 1.2
Version:
$Revision: 1.6 $($Author: dvoet $ / $Date: 2003/05/05 21:21:30 $)
Author:
Greg Hinkle, January 2003

Nested Class Summary
static class BoundedBufferPerformanceLogger.TimingInfo
          This inner class supports the tracking of timings on a single tracked item.
 
Field Summary
private static String PAD
          Holds the characters used to pad in the pad method.
protected  Map timingMap
          A synchronized map of TimingInfo objects to the tracked object
protected  int trackedTimings
          Holds the number of timings to track for statistics generation.
 
Fields inherited from class org.sape.carbon.services.perflog.DefaultPerformanceLogger
INVALID_TIME
 
Constructor Summary
BoundedBufferPerformanceLogger()
           
 
Method Summary
 void configure(ComponentConfiguration configuration)
          Configure the component.
 String getReport()
          Returns a string report of timings that are being tracked by this perfomance logger.
private  String pad(String str, int len)
          Pads the information fields to a fixed length for display.
protected  void registerTiming(Object trackedObject, long time)
          This implementation will add a new TimingInfo object to the main tracking map if one is not found corresponding to the tracked action.
protected  void trackTiming(Object trackedObject, long time)
          This implementation adds additional steps to track a set of timings in order to calculate statistics on the executions.
 
Methods inherited from class org.sape.carbon.services.perflog.DefaultPerformanceLogger
clearStack, enabled, end, getCallStack, logCallStack, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sape.carbon.services.perflog.PerformanceLogger
end, start
 

Field Detail

timingMap

protected Map timingMap
A synchronized map of TimingInfo objects to the tracked object


trackedTimings

protected int trackedTimings
Holds the number of timings to track for statistics generation.


PAD

private static final String PAD
Holds the characters used to pad in the pad method.

See Also:
pad(java.lang.String, int), Constant Field Values
Constructor Detail

BoundedBufferPerformanceLogger

public BoundedBufferPerformanceLogger()
Method Detail

trackTiming

protected void trackTiming(Object trackedObject,
                           long time)
This implementation adds additional steps to track a set of timings in order to calculate statistics on the executions.

Overrides:
trackTiming in class DefaultPerformanceLogger
Parameters:
trackedObject - the object that is being timed
time - the duration of the execution to track

registerTiming

protected void registerTiming(Object trackedObject,
                              long time)
This implementation will add a new TimingInfo object to the main tracking map if one is not found corresponding to the tracked action. It will then register the supplied timing with that object.

Parameters:
trackedObject - the object being tracked
time - the time tracked of the call

pad

private String pad(String str,
                   int len)
Pads the information fields to a fixed length for display.

Parameters:
str - the string to pad
len - the max length to pad to
Returns:
a new padded version of the string

getReport

public String getReport()
Returns a string report of timings that are being tracked by this perfomance logger.

Specified by:
getReport in interface ReportingPerformanceLogger
Returns:
A report of information for this logger

configure

public void configure(ComponentConfiguration configuration)
Configure the component. This is preceded and followed by the suspend and resume operations if they are available on the component.

Specified by:
configure in interface Configurable
Parameters:
configuration - BoundedBufferPerformanceLoggerConfiguration to configure this component
Throws:
LifecycleException


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.