com.commsen.stopwatch.engines
Class MemoryStopwatchEngine

java.lang.Object
  extended by com.commsen.stopwatch.engines.DefaultStopwatchEngine
      extended by com.commsen.stopwatch.engines.MemoryStopwatchEngine
All Implemented Interfaces:
StopwatchEngine

public class MemoryStopwatchEngine
extends DefaultStopwatchEngine

This class extends default Stopwatch's engine to provide information about memory usage. Note: the memory usage measurements performed by this class are FAR FROM ACCURATE.

As of now I'm not aware of how one can measure the actual amount of memory given object uses. This class simply remembers the amount of memory used by JVM at the time of starting the measurement and compares it to the amount of memory used by JVM at the time of completing the measurement. This of course may have nothing to do the truth if some other threads are running and consuming memory or for example GC is started while measuring.

So the results may vary from "almost correct" in the case of single threaded application to "pure fiction" in case of heavily loaded, multi threaded application

To use MemoryStopwatchEngine with Stopwatch one can :

Author:
Milen Dyankov

Constructor Summary
MemoryStopwatchEngine()
           
 
Method Summary
 long begin(java.lang.String group, java.lang.String label)
          Method called when mensuration is started.
 void end(long id)
          Method called when mensuration is stopped.
protected  org.apache.log4j.Logger getLogger()
           
 
Methods inherited from class com.commsen.stopwatch.engines.DefaultStopwatchEngine
getPersistenceMode, getProperties, getStorage, getStorageClass, getStorageManager, isDebug, isDebugEnabled, pause, resume, setDebugEnabled, setPersistenceMode, setProperties, setStorage, skip, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryStopwatchEngine

public MemoryStopwatchEngine()
Method Detail

end

public void end(long id)
Description copied from interface: StopwatchEngine
Method called when mensuration is stopped. It is possible to call this method multiple times with the same id, however the engine should process only the first call.

Specified by:
end in interface StopwatchEngine
Overrides:
end in class DefaultStopwatchEngine
Parameters:
id - Unique ID representing the actual measurment that need to be stopped.
See Also:
DefaultStopwatchEngine.end(long)

begin

public long begin(java.lang.String group,
                  java.lang.String label)
Description copied from interface: StopwatchEngine
Method called when mensuration is started.

Specified by:
begin in interface StopwatchEngine
Overrides:
begin in class DefaultStopwatchEngine
Parameters:
group - the name of the group this measurment should be placed in
label - how this measurment should be labeled
Returns:
Unique ID representing current measurment.
See Also:
DefaultStopwatchEngine.begin(java.lang.String, java.lang.String)

getLogger

protected org.apache.log4j.Logger getLogger()
Overrides:
getLogger in class DefaultStopwatchEngine


Copyright © 2006-2008 Commsen International. All Rights Reserved.