Package com.badlogic.gdx.utils
Class PerformanceCounter
- java.lang.Object
-
- com.badlogic.gdx.utils.PerformanceCounter
-
public class PerformanceCounter extends java.lang.ObjectClass to keep track of the time and load (percentage of total time) a specific task takes. Callstart()just before starting the task andstop()right after. You can do this multiple times if required. Every render or update calltick()to update the values. ThetimeFloatCounterprovides access to the minimum, maximum, average, total and current time (in seconds) the task takes. Likewise for theloadvalue, which is the percentage of the total time.
-
-
Field Summary
Fields Modifier and Type Field Description floatcurrentThe current value in seconds, you can manually increase this using your own timing mechanism if needed, if you do so, you also need to updatevalid.FloatCounterloadThe load value of this counterjava.lang.StringnameThe name of this counterFloatCountertimeThe time value of this counter (seconds)booleanvalidFlag to indicate that the current value is valid, you need to set this to true if using your own timing mechanism
-
Constructor Summary
Constructors Constructor Description PerformanceCounter(java.lang.String name)PerformanceCounter(java.lang.String name, int windowSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidreset()Resets this performance counter to its defaults values.voidstart()Start counting, call this method just before performing the task you want to keep track of.voidstop()Stop counting, call this method right after you performed the task you want to keep track of.voidtick()Updates the time and load counters and resets the time.voidtick(float delta)Updates the time and load counters and resets the time.java.lang.StringtoString()StringBuildertoString(StringBuilder sb)Creates a string in the form of "name [time: value, load: value]"
-
-
-
Field Detail
-
time
public final FloatCounter time
The time value of this counter (seconds)
-
load
public final FloatCounter load
The load value of this counter
-
name
public final java.lang.String name
The name of this counter
-
current
public float current
The current value in seconds, you can manually increase this using your own timing mechanism if needed, if you do so, you also need to updatevalid.
-
valid
public boolean valid
Flag to indicate that the current value is valid, you need to set this to true if using your own timing mechanism
-
-
Method Detail
-
tick
public void tick()
Updates the time and load counters and resets the time. Callstart()to begin a new count. The values are only valid after at least two calls to this method.
-
tick
public void tick(float delta)
Updates the time and load counters and resets the time. Callstart()to begin a new count.- Parameters:
delta- The time since the last call to this method
-
start
public void start()
Start counting, call this method just before performing the task you want to keep track of. Callstop()when done.
-
stop
public void stop()
Stop counting, call this method right after you performed the task you want to keep track of. Callstart()again when you perform more of that task.
-
reset
public void reset()
Resets this performance counter to its defaults values.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
public StringBuilder toString(StringBuilder sb)
Creates a string in the form of "name [time: value, load: value]"
-
-