public class AnimationBenchmark extends Object
Animation instances wrapped by
track(Animation).
Enable benchmarking by setting the BON constant to true.
| Modifier and Type | Class and Description |
|---|---|
static class |
AnimationBenchmark.AnimationTimeoutException
Thrown by
wait(String, long) when the animation did not complete within the specified
timeout. |
static class |
AnimationBenchmark.TrackedAnimation
An
Animation decorator that records timing data for benchmarking. |
| Modifier and Type | Field and Description |
|---|---|
static String |
ENABLED_CONSTANT
Boolean BON constant that enables animation benchmarking.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addNextLabel(String label)
Queues a label to be associated with the next
AnimationBenchmark.TrackedAnimation created, and sets up the synchronization
lock used by wait(String, long). |
static void |
clear()
Resets all benchmarking state: pending labels, completion locks, and completed animations.
|
static Animation |
track(Animation animation)
Wraps the given animation in a
AnimationBenchmark.TrackedAnimation that records timing data. |
static AnimationBenchmark.TrackedAnimation |
wait(String label,
long timeout)
Blocks the calling thread until the
AnimationBenchmark.TrackedAnimation registered under label completes, or until
the timeout elapses. |
public static final String ENABLED_CONSTANT
true and a label was queued, an animation
started via Animator is automatically wrapped in a AnimationBenchmark.TrackedAnimation before execution.
Constant name: "ej.mwt.debug.animation.benchmark.enabled".
public static void addNextLabel(String label)
AnimationBenchmark.TrackedAnimation created, and sets up the synchronization
lock used by wait(String, long).
Must be called before the animation is started. Labels are consumed in FIFO order.
label - the label to associate with the next benchmarked animationpublic static void clear()
Call this between test runs to ensure a clean state.
public static Animation track(Animation animation)
AnimationBenchmark.TrackedAnimation that records timing data.
If a label was queued via addNextLabel(String), it is consumed (FIFO) and associated with the returned
animation. Otherwise, the animation is not tracked.
animation - the animation to wrap; must not be nullAnimationBenchmark.TrackedAnimation delegating to animationpublic static AnimationBenchmark.TrackedAnimation wait(String label, long timeout) throws AnimationBenchmark.AnimationTimeoutException, InterruptedException
AnimationBenchmark.TrackedAnimation registered under label completes, or until
the timeout elapses.
addNextLabel(String) must be called with the same label before the animation is started, otherwise an
IllegalStateException is thrown.
label - the label of the animation to wait fortimeout - the maximum time to wait, in millisecondsIllegalStateException - if called from the UI thread or no animation was registered with the given label via
addNextLabel(String)AnimationBenchmark.AnimationTimeoutException - if the animation did not complete within the timeoutInterruptedException - if the calling thread is interrupted while waiting