Class StatCollector

java.lang.Object
com.ardor3d.util.stat.StatCollector

public abstract class StatCollector extends Object
This class acts as a centralized data store for statistics. As data is added to the collector, a sum total is kept as well as the total number of data samples given for the particular stat.
  • Field Details

    • maxSamples

      protected static int maxSamples
      How many distinct past aggregate samples are kept before the oldest one is dropped on add. You can multiply this by the time sample rate to determine the total history length in time.
    • current

      protected static HashMap<StatType,StatValue> current
      Our map of current stat values. Current means values that have been collected within the current time sample. For example, if sampleRate = 1.0, then current will hold values collected since the last 1 second ping.
    • historical

      protected static List<MultiStatSample> historical
    • sampleRateMS

      protected static double sampleRateMS
      How long to gather stats as a single unit before pushing them onto the historical stack.
    • lastSampleTime

      protected static double lastSampleTime
    • lastTimeCheckMS

      protected static double lastTimeCheckMS
    • listeners

      protected static List<StatListener> listeners
    • startOffset

      protected static double startOffset
    • ignoreStats

      protected static boolean ignoreStats
    • timeStatStack

      protected static Stack<StatType> timeStatStack
    • timedStats

      protected static HashSet<StatType> timedStats
    • timer

      protected static Timer timer
    • TO_MS

      protected static final double TO_MS
    • pausedTime

      protected static long pausedTime
    • pausedStartTime

      protected static long pausedStartTime
  • Constructor Details

    • StatCollector

      public StatCollector()
  • Method Details

    • init

      public static void init(long sampleRateMS, int maxHistorical)
      Construct a new StatCollector.
      Parameters:
      sampleRateMS - The amount of time between aggregated samples in milliseconds.
      maxHistorical - the maximum sample count
    • addStat

      public static void addStat(StatType type, double statValue)
    • startStat

      public static void startStat(StatType type)
    • endStat

      public static void endStat(StatType type)
    • update

      public static void update()
    • addStatListener

      public static void addStatListener(StatListener listener)
      Add a listener to the pool of listeners that are notified when a new stats aggregate is created (at the end of each time sample).
      Parameters:
      listener - the listener to add
    • removeStatListener

      public static boolean removeStatListener(StatListener listener)
      Removes a listener from the pool of listeners that are notified when a new stats aggregate is created (at the end of each time sample).
      Parameters:
      listener - the listener to remove
      Returns:
      true if the listener has been successfully removed
    • removeAllListeners

      public static void removeAllListeners()
      Cleans the listener pool of all listeners.
    • addTimedStat

      public static void addTimedStat(StatType type)
      Add a type to the set of stat types that are paid attention to when doing timed stat checking.
      Parameters:
      type - the listener to add
    • removeTimedStat

      public static boolean removeTimedStat(StatType type)
      Removes a type from the set of stat types that are paid attention to when doing timed stat checking.
      Parameters:
      type - the listener to remove
      Returns:
      true if the timed stat of this type has been successfully removed
    • removeAllTimedStats

      public static void removeAllTimedStats()
      Cleans the set of stat types we paid attention to when doing timed stat checking.
    • fireActionEvent

      public static void fireActionEvent()
      Notifies all registered listeners that a new stats aggregate was created.
    • getStartOffset

      public static double getStartOffset()
    • getSampleRate

      public static double getSampleRate()
    • setSampleRate

      public static void setSampleRate(long sampleRateMS)
    • setMaxSamples

      public static void setMaxSamples(int samples)
    • getMaxSamples

      public static int getMaxSamples()
    • getHistorical

      public static List<MultiStatSample> getHistorical()
    • lastStats

      public static MultiStatSample lastStats()
    • isIgnoreStats

      public static boolean isIgnoreStats()
    • setIgnoreStats

      public static void setIgnoreStats(boolean ignoreStats)
    • hasHistoricalStat

      public static boolean hasHistoricalStat(StatType type)
    • resetTimedStack

      public static void resetTimedStack()
      Call this if you've caught an error, etc and you need to reset timed stats collecting. NOTE: You must ensure you are not inside a START/END timed block, (or you recreate any necessary start calls) otherwise when endStat is called a stack exception will occur.
    • pause

      public static void pause()
    • resume

      public static void resume()