Package org.droolsassert.util
Class PerfStat
- java.lang.Object
-
- org.droolsassert.util.PerfStat
-
public class PerfStat extends Object
Performance statistic per type (optional) and name. Exposed via MBean server to monitor in real-time with default 4s aggregation time (jvisualvm mbean charts refresh interval). Output statistic from this VM or deliver serializable and merge from several VMs.private PerfStat methodPerf = new PerfStat("type", "name") ... public void myMethod() { methodPerf.start(); ... methodPerf.stop(); } }- See Also:
start(),stop(),getPerfStat(),StopWatch
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfinalize()static longgetDefaultAggregationPeriodMs()StringgetFullName()static StringgetJmxDomain()StringgetName()static TreeMap<String,TreeMap<String,StatImpl>>getPerfStat()Performance statistic for all types and namesstatic StatgetPerfStat(String name)Performance statistic for name (if type was not used)static StatgetPerfStat(String type, String name)Performance statistic for type and nameStatgetStat()org.apache.commons.lang3.time.StopWatchgetStopWatch()StringgetType()static voidmerge(Map<String,Map<String,StatImpl>> rhsStatsByType)You may want to merge performance statistic from other JVMsvoidreset()Reset statisticstatic voidresetAll()Reset statistic for all types and namesstatic voidsetDefaultAggregationPeriodMs(long defaultAggregationPeriodMs)static voidsetJmxDomain(String jmxDomain)PerfStatstart()Start to measure execution time for current thread.
Reset sample (period) values if aggregation time threshold passed over.longstop()Stop to measure execution time for current thread, update performance statistic for the name.
If stop was not executed for some reason and then start will be called again by the same thread then current leap will be counted as failed.StringtoString()
-
-
-
Method Detail
-
getJmxDomain
public static String getJmxDomain()
-
setJmxDomain
public static void setJmxDomain(String jmxDomain)
-
getDefaultAggregationPeriodMs
public static long getDefaultAggregationPeriodMs()
-
setDefaultAggregationPeriodMs
public static void setDefaultAggregationPeriodMs(long defaultAggregationPeriodMs)
-
getPerfStat
public static Stat getPerfStat(String name)
Performance statistic for name (if type was not used)- Parameters:
name-
-
getPerfStat
public static Stat getPerfStat(String type, String name)
Performance statistic for type and name- Parameters:
name-
-
getPerfStat
public static TreeMap<String,TreeMap<String,StatImpl>> getPerfStat()
Performance statistic for all types and names
-
merge
public static void merge(Map<String,Map<String,StatImpl>> rhsStatsByType)
You may want to merge performance statistic from other JVMs
-
resetAll
public static void resetAll()
Reset statistic for all types and names
-
finalize
protected void finalize() throws Throwable
-
start
public PerfStat start()
Start to measure execution time for current thread.
Reset sample (period) values if aggregation time threshold passed over.
-
stop
public long stop()
Stop to measure execution time for current thread, update performance statistic for the name.
If stop was not executed for some reason and then start will be called again by the same thread then current leap will be counted as failed.
-
reset
public void reset()
Reset statistic
-
getStopWatch
public org.apache.commons.lang3.time.StopWatch getStopWatch()
-
getStat
public Stat getStat()
-
getType
public String getType()
-
getName
public String getName()
-
getFullName
public String getFullName()
-
-