public static class AnimationBenchmark.TrackedAnimation extends Object implements Animation
Animation decorator that records timing data for benchmarking.
Each call to tick(long) appends the platform time to an internal list of timestamps. After the animation
completes (i.e., after tick(long) returns false), this data is available via
getTimestamps(), getFrameTimes(), getAverageFps(), getDuration(),
getMaxFrameTime(), and getDroppedFramesCount(long).
Instance is automatically returned by AnimationBenchmark.wait(String, long) when it stops. The result
methods listed above are only guaranteed to reflect a fully consistent state after a corresponding
AnimationBenchmark.wait(String, long) call has returned for labeled animations.
| Constructor and Description |
|---|
TrackedAnimation(Animation delegate,
String label) |
| Modifier and Type | Method and Description |
|---|---|
float |
getAverageFps()
Returns the average frame rate of this animation over its entire duration.
|
int |
getDroppedFramesCount(long threshold)
Returns the number of frames whose inter-frame duration was greater than or equal to the given threshold.
|
long |
getDuration()
Returns the total duration of this animation in milliseconds.
|
long[] |
getFrameTimes()
Returns the list of inter-frame durations for this animation, in milliseconds.
|
String |
getLabel()
Returns the label associated with this animation.
|
long |
getMaxFrameTime()
Returns the maximum inter-frame duration recorded for this animation, in milliseconds.
|
long[] |
getTimestamps()
Returns a copy of the tick timestamps recorded for this animation.
|
boolean |
tick(long platformTimeMillis)
Called by the animator to step this animation.
|
public float getAverageFps()
public int getDroppedFramesCount(long threshold)
A frame is considered dropped when its duration meets or exceeds threshold: the renderer took so long
that a visible stall occurred. A common threshold is twice the expected frame budget — for example, 80ms for
a 25 fps target (2 × 40ms).
threshold - the minimum inter-frame duration in milliseconds to consider a frame as dropped; must be positivethresholdpublic long getDuration()
Computed as the elapsed time between the first and last tick. Returns 0 if fewer than two ticks were
recorded (e.g., the animation completed in a single tick).
0 if not enough ticks were recordedpublic long[] getFrameTimes()
The i-th element is the elapsed time between the i-th and (i+1)-th tick. This list therefore has one fewer
entry than getTimestamps(). Returns an empty list if fewer than two ticks were recorded.
public String getLabel()
public long getMaxFrameTime()
A high value indicates that the renderer stalled on that frame. Returns 0 if fewer than two ticks
were recorded.
0 if not enough ticks were recordedpublic long[] getTimestamps()
Each value is a platform time in milliseconds as returned by Util.platformTimeMillis(). The first
entry is the time of the first tick; the last entry is the time of the final tick. The list is empty if the
animation has not started yet.
public boolean tick(long platformTimeMillis)
Records the start time on the first call and delegates to the wrapped animation. When the wrapped animation
stops, records the stop time, links this instance to the associated lock, and notifies any thread blocked in
AnimationBenchmark.wait(String, long).