net.sf.spif
Class StoreProfiler

java.lang.Object
  |
  +--net.sf.spif.StoreChain
        |
        +--net.sf.spif.StoreProfiler

public class StoreProfiler
extends StoreChain

A store which logs the time spent on each get and put call passing through as fine messages to a java.util.logging.Logger named by this class name. Note: This class is not thread safe - multiple threads may produce incorrect measures.

Version:
$Id: StoreProfiler.java,v 1.2 2003/02/05 22:15:45 bratseth Exp $
Author:
Jon S Bratseth

Field Summary
protected static java.util.logging.Logger log
          The logger used by this class
 
Fields inherited from class net.sf.spif.StoreChain
chained
 
Constructor Summary
StoreProfiler()
          Creates a store profiler which logs each access
StoreProfiler(boolean log)
          Creates a store profiler
 
Method Summary
 java.lang.Object get(Id id, boolean writeable)
          Returns an object from the store.
 long getGetAverageTime()
          Return the average get time in milliseconds
 long getGetCount()
          Return the total number of gets
 long getGetTotalTime()
          Return the total time spent getting in milliseconds
 long getPutAverageTime()
          Return the average put time in milliseconds
 long getPutCount()
          Return the total number of puts
 long getPutTotalTime()
          Return the total time spent putting in milliseconds
 java.lang.String getReportString()
          Returns a human-readable string containing the statistics gethered
 Id put(Id id, java.lang.Object object)
          Puts an object in the store.
 void reset()
          Resets all measures to 0
 
Methods inherited from class net.sf.spif.StoreChain
clear, equals, getChained, getChained, getChained, hashCode, remove, setChained
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static java.util.logging.Logger log
The logger used by this class

Constructor Detail

StoreProfiler

public StoreProfiler()
Creates a store profiler which logs each access


StoreProfiler

public StoreProfiler(boolean log)
Creates a store profiler

Parameters:
log - true if accesses should be logged, false if averages should be recorded only
Method Detail

get

public java.lang.Object get(Id id,
                            boolean writeable)
Description copied from class: StoreChain

Returns an object from the store.

This default implementation just forwards to the chained. for (optional) use by subclasses.

Overrides:
get in class StoreChain
Parameters:
id - the id of the object to return
Returns:
the object, or null if the object could not be retrieved or if the input id was null

put

public Id put(Id id,
              java.lang.Object object)
Description copied from class: StoreChain

Puts an object in the store. The objects may be new, or previously acquired by getting writeable. It is an error to attempt to put an existing object not previously acquired by getting writeable.

This default implementation just forwards to the chained. for (optional) use by subclasses.

Overrides:
put in class StoreChain
Parameters:
id - the id of the object to put. May be null
object - the object to put. May be null
Returns:
the id of this object. This will usually be (and is in this default implementation) the input id, unless the given id is null and there is an id generating service on the store chain

reset

public void reset()
Resets all measures to 0


getGetTotalTime

public long getGetTotalTime()
Return the total time spent getting in milliseconds


getGetCount

public long getGetCount()
Return the total number of gets


getGetAverageTime

public long getGetAverageTime()
Return the average get time in milliseconds


getPutTotalTime

public long getPutTotalTime()
Return the total time spent putting in milliseconds


getPutCount

public long getPutCount()
Return the total number of puts


getPutAverageTime

public long getPutAverageTime()
Return the average put time in milliseconds


getReportString

public java.lang.String getReportString()
Returns a human-readable string containing the statistics gethered



Spif 1.01 (2003-04-03). http://spif.sf.net