|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.tum.cs.commons.system.PerformanceMonitor
public class PerformanceMonitor
Combines a timer and a memory monitor in a simple utility class. Measures
both total memory and the delta between start()
and stop()
.
In order to avoid programming mistakes, the calls to the methods
start()
and stop()
must
adhere to a simple protocol:
The PerformanceMonitor
can be in on of the three states NOT_RUN,
RUNNING, FINISHED.
start()
May only be called in state NOT_RUN and
stop()
may only be called in state RUNNING.
All other calls to start()
and
stop()
result in IllegalArgumentException
s
Method Summary | |
---|---|
static PerformanceMonitor |
create()
Convenience factory method: Creates a new PerformanceMonitor and
starts it. |
static PerformanceMonitor |
create(boolean useMemoryMonitor)
Convenience factory method: Creates a new PerformanceMonitor and
starts it. |
long |
getDeltaMemUsageInBytes()
Gets the delta in memory consumption in bytes |
long |
getDeltaMemUsageInKBs()
Gets the delta in memory consumption in kilobytes |
long |
getMaxMemUsageInBytes()
Gets the maximal memory consumption in bytes |
long |
getMaxMemUsageInKBs()
Gets the maximal memory consumption in kilobytes |
long |
getMilliseconds()
Gets the measured time in milliseconds |
long |
getSeconds()
Gets the measured time in seconds. |
void |
start()
Starts the PerformanceMonitor . |
void |
stop()
Stops the PerformanceMonitor . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static PerformanceMonitor create(boolean useMemoryMonitor)
PerformanceMonitor
and
starts it.
useMemoryMonitor
- detemines whether the PerformanceMonitor internally uses a
MemoryMonitor
to measure memory consumption. This
requires more resources, since the MemoryMonitor
runs
its own thread, but promises more precise measurement of
maximum memory consumption.public static PerformanceMonitor create()
PerformanceMonitor
and
starts it. PerformanceMonitor does not use a MemoryMonitor internally
public void start()
PerformanceMonitor
. It will measure time and maximal
memory consumption until the method stop()
is
called.
This method may only be called, if the PerformanceMonitor
is in
state NOT_RUN. (i.e., after it has been created).
All subsequent calls to this method will result in a
IllegalStateException
public void stop()
PerformanceMonitor
.
This method may only be called, if the PerformanceMonitor
is in
state RUNNING. (i.e., after a call to start()
).
If the PerformanceMonitor
is in any other state, a call to this
method results in an IllegalStateException
public long getSeconds()
public long getMilliseconds()
public long getMaxMemUsageInBytes()
public long getMaxMemUsageInKBs()
public long getDeltaMemUsageInBytes()
public long getDeltaMemUsageInKBs()
|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |