Class AnimationBenchmark.TrackedAnimation

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      java.lang.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TrackedAnimation

        public TrackedAnimation​(Animation delegate,
                                java.lang.String label)
    • Method Detail

      • getLabel

        public java.lang.String getLabel()
        Returns the label associated with this animation.
        Returns:
        the label
      • getAverageFps

        public float getAverageFps()
        Returns the average frame rate of this animation over its entire duration.
        Returns:
        the average frames per second
      • getTimestamps

        public long[] getTimestamps()
        Returns a copy of the tick timestamps recorded for this animation.

        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.

        Returns:
        a snapshot of the tick timestamps, in chronological order
      • getFrameTimes

        public long[] getFrameTimes()
        Returns the list of inter-frame durations for this animation, in milliseconds.

        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.

        Returns:
        the array of inter-frame durations, in milliseconds
      • getMaxFrameTime

        public long getMaxFrameTime()
        Returns the maximum inter-frame duration recorded for this animation, in milliseconds.

        A high value indicates that the renderer stalled on that frame. Returns 0 if fewer than two ticks were recorded.

        Returns:
        the maximum inter-frame duration in milliseconds, or 0 if not enough ticks were recorded
      • getDroppedFramesCount

        public int getDroppedFramesCount​(long threshold)
        Returns the number of frames whose inter-frame duration was greater than or equal to the given 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).

        Parameters:
        threshold - the minimum inter-frame duration in milliseconds to consider a frame as dropped; must be positive
        Returns:
        the number of frames whose duration is >= threshold
      • getDuration

        public long getDuration()
        Returns the total duration of this animation in milliseconds.

        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).

        Returns:
        the animation duration in milliseconds, or 0 if not enough ticks were recorded
      • tick

        public boolean tick​(long platformTimeMillis)
        Called by the animator to step this animation.

        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).

        Specified by:
        tick in interface Animation
        Parameters:
        platformTimeMillis - the current time in milliseconds, based on Util.platformTimeMillis()
        Returns:
        true if the animation must continue, false if it must stop