public abstract class PerformanceTracker
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PerformanceTracker.SceneAccessor |
Modifier and Type | Field and Description |
---|---|
private int |
avgFramesTotal |
private long |
avgPulsesStartTime |
private int |
avgPulsesTotal |
private long |
avgStartTime |
private boolean |
firstPulse |
private float |
instantFPS |
private int |
instantFPSFrames |
private long |
instantFPSStartTime |
private float |
instantPulses |
private int |
instantPulsesFrames |
private long |
instantPulsesStartTime |
private java.lang.Runnable |
onFirstPulse
Called on the first rendering pulse since this tracker has been created.
|
private java.lang.Runnable |
onPulse
Called on every rendering pulse.
|
private java.lang.Runnable |
onRenderedFrameTask |
private boolean |
perfLoggingEnabled |
private static PerformanceTracker.SceneAccessor |
sceneAccessor
This class provides a way to track performance metrics such as first
paint, instant fps, average fps.
|
Constructor and Description |
---|
PerformanceTracker() |
Modifier and Type | Method and Description |
---|---|
private void |
calcFPS() |
private void |
calcPulses() |
abstract void |
doLogEvent(java.lang.String s) |
abstract void |
doOutputLog() |
void |
frameRendered() |
float |
getAverageFPS()
Returns the average FPS in the time period since the least call
to
resetAverageFPS() . |
float |
getAveragePulses()
Returns the average pulses per second in the time period since the least call
to
resetAveragePulses() . |
float |
getInstantFPS()
Returns the number of frames rendered in the last second or so.
|
float |
getInstantPulses()
Returns the number of pulses received in the last second or so.
|
java.lang.Runnable |
getOnFirstPulse() |
java.lang.Runnable |
getOnPulse() |
java.lang.Runnable |
getOnRenderedFrameTask() |
static PerformanceTracker |
getSceneTracker(Scene scene)
Creates a
PerformanceTracker for this scene. |
static boolean |
isLoggingEnabled()
Use method instead of def to avoid explicit initialization which could
be circular (this class may be referenced before the toolkit is initialized).
|
protected boolean |
isPerfLoggingEnabled() |
static void |
logEvent(java.lang.String desc)
Log an event with given description.
|
protected abstract long |
nanoTime() |
static void |
outputLog()
Output full log of events so far.
|
void |
pulse() |
static void |
releaseSceneTracker(Scene scene)
Removes the tracker from the scene.
|
void |
resetAverageFPS() |
void |
resetAveragePulses() |
void |
setOnFirstPulse(java.lang.Runnable value) |
void |
setOnPulse(java.lang.Runnable value) |
void |
setOnRenderedFrameTask(java.lang.Runnable value) |
protected void |
setPerfLoggingEnabled(boolean value) |
static void |
setSceneAccessor(PerformanceTracker.SceneAccessor accessor) |
private void |
updateInstantFps() |
private void |
updateInstantPulses() |
private static PerformanceTracker.SceneAccessor sceneAccessor
Typical use scenario is to obtain the tracker from a Scene
, and use it
to get instant or average fps. It is also possible to execute a user
function every time the scene is repainted onPulse
.
private boolean perfLoggingEnabled
private boolean firstPulse
private float instantFPS
private int instantFPSFrames
private long instantFPSStartTime
private long avgStartTime
private int avgFramesTotal
private float instantPulses
private int instantPulsesFrames
private long instantPulsesStartTime
private long avgPulsesStartTime
private int avgPulsesTotal
private java.lang.Runnable onPulse
private java.lang.Runnable onFirstPulse
private java.lang.Runnable onRenderedFrameTask
public static boolean isLoggingEnabled()
public static PerformanceTracker getSceneTracker(Scene scene)
PerformanceTracker
for this scene. There could be only one
performance tracker per scene so once a tracker is created for a scene it
will be returned for each getSceneTracker
call until the tracker
is released with releaseSceneTracker(Scene)
. PerformanceTracker
associated with the scene
or null if the tracker couldn't be created.public static void releaseSceneTracker(Scene scene)
public static void setSceneAccessor(PerformanceTracker.SceneAccessor accessor)
public static void logEvent(java.lang.String desc)
public static void outputLog()
protected boolean isPerfLoggingEnabled()
protected void setPerfLoggingEnabled(boolean value)
protected abstract long nanoTime()
public abstract void doOutputLog()
public abstract void doLogEvent(java.lang.String s)
public float getInstantFPS()
public float getAverageFPS()
resetAverageFPS()
.public void resetAverageFPS()
public float getInstantPulses()
public float getAveragePulses()
resetAveragePulses()
.public void resetAveragePulses()
public void pulse()
public void frameRendered()
private void calcPulses()
private void calcFPS()
private void updateInstantFps()
private void updateInstantPulses()
public void setOnPulse(java.lang.Runnable value)
public java.lang.Runnable getOnPulse()
public void setOnFirstPulse(java.lang.Runnable value)
public java.lang.Runnable getOnFirstPulse()
public void setOnRenderedFrameTask(java.lang.Runnable value)
public java.lang.Runnable getOnRenderedFrameTask()