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:
  • Constructor Details

    • PerfStat

      public PerfStat(String name)
    • PerfStat

      public PerfStat(String type, String name)
    • PerfStat

      public PerfStat(String name, long aggregationPeriodMs)
    • PerfStat

      public PerfStat(String type, String name, long aggregationPeriodMs)
  • Method Details

    • 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
      Overrides:
      finalize in class Object
      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()
    • toString

      public String toString()
      Overrides:
      toString in class Object