Package com.ardor3d.util.stat
Class StatCollector
java.lang.Object
com.ardor3d.util.stat.StatCollector
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 Summary
Modifier and TypeFieldDescriptionOur map of current stat values.protected static List
<MultiStatSample> protected static boolean
protected static double
protected static double
protected static List
<StatListener> protected static int
How many distinct past aggregate samples are kept before the oldest one is dropped on add.protected static long
protected static long
protected static double
How long to gather stats as a single unit before pushing them onto the historical stack.protected static double
protected static Timer
protected static final double
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
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).static void
addTimedStat
(StatType type) Add a type to the set of stat types that are paid attention to when doing timed stat checking.static void
static void
Notifies all registered listeners that a new stats aggregate was created.static List
<MultiStatSample> static int
static double
static double
static boolean
hasHistoricalStat
(StatType type) static void
init
(long sampleRateMS, int maxHistorical) Construct a new StatCollector.static boolean
static MultiStatSample
static void
pause()
static void
Cleans the listener pool of all listeners.static void
Cleans the set of stat types we paid attention to when doing timed stat checking.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).static boolean
removeTimedStat
(StatType type) Removes a type from the set of stat types that are paid attention to when doing timed stat checking.static void
Call this if you've caught an error, etc and you need to reset timed stats collecting.static void
resume()
static void
setIgnoreStats
(boolean ignoreStats) static void
setMaxSamples
(int samples) static void
setSampleRate
(long sampleRateMS) static void
static void
update()
-
Field Details
-
maxSamples
protected static int maxSamplesHow 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
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
-
sampleRateMS
protected static double sampleRateMSHow 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
-
startOffset
protected static double startOffset -
ignoreStats
protected static boolean ignoreStats -
timeStatStack
-
timedStats
-
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
-
startStat
-
endStat
-
update
public static void update() -
addStatListener
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
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
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
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
-
lastStats
-
isIgnoreStats
public static boolean isIgnoreStats() -
setIgnoreStats
public static void setIgnoreStats(boolean ignoreStats) -
hasHistoricalStat
-
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()
-