Package org.jgroups.util
Class Profiler
- java.lang.Object
-
- org.jgroups.util.Profiler
-
- All Implemented Interfaces:
DiagnosticsHandler.ProbeHandler
public class Profiler extends java.lang.Object implements DiagnosticsHandler.ProbeHandler
WrapsAverageMinMaxand provides an impl ofDiagnosticsHandler.ProbeHandler. Note that this class in unsynchronized and needs external synchronization.- Since:
- 4.0
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected AverageMinMaxavgprotected java.lang.Stringnameprotected java.util.concurrent.TimeUnitunit
-
Constructor Summary
Constructors Constructor Description Profiler(java.lang.String name, java.util.concurrent.TimeUnit unit)Creates a Profiler instance which will reply to key 'name'.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Profileradd(long time)doubleaverage()Profilerclear()longcount()java.util.Map<java.lang.String,java.lang.String>handleProbe(java.lang.String... keys)Handles a probe.longmax()longmin()java.lang.String[]supportedKeys()Returns a list of supported keysjava.lang.StringtoString()protected static java.lang.StringtoString(java.util.concurrent.TimeUnit unit)
-
-
-
Field Detail
-
avg
protected final AverageMinMax avg
-
name
protected final java.lang.String name
-
unit
protected final java.util.concurrent.TimeUnit unit
-
-
Constructor Detail
-
Profiler
public Profiler(java.lang.String name, java.util.concurrent.TimeUnit unit)Creates a Profiler instance which will reply to key 'name'.- Parameters:
name- The name under which the profiler will register itselfunit- The unit of measurement - only nanos, micros and millis are supported
-
-
Method Detail
-
add
public Profiler add(long time)
-
min
public long min()
-
max
public long max()
-
average
public double average()
-
count
public long count()
-
clear
public Profiler clear()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
handleProbe
public java.util.Map<java.lang.String,java.lang.String> handleProbe(java.lang.String... keys)
Description copied from interface:DiagnosticsHandler.ProbeHandlerHandles a probe. For each key that is handled, the key and its result should be in the returned map.- Specified by:
handleProbein interfaceDiagnosticsHandler.ProbeHandler- Returns:
- Map
. A map of keys and values. A null return value is permissible.
-
supportedKeys
public java.lang.String[] supportedKeys()
Description copied from interface:DiagnosticsHandler.ProbeHandlerReturns a list of supported keys- Specified by:
supportedKeysin interfaceDiagnosticsHandler.ProbeHandler
-
toString
protected static java.lang.String toString(java.util.concurrent.TimeUnit unit)
-
-