Package ej.mwt.animation
Class AnimationBenchmark
- java.lang.Object
-
- ej.mwt.animation.AnimationBenchmark
-
public class AnimationBenchmark extends java.lang.ObjectStatic utility for benchmarking animations: tracks duration and frame rate ofAnimationinstances wrapped bytrack(Animation).Enable benchmarking by setting the
BON constanttotrue.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAnimationBenchmark.AnimationTimeoutExceptionThrown bywait(String, long)when the animation did not complete within the specified timeout.static classAnimationBenchmark.TrackedAnimationAnAnimationdecorator that records timing data for benchmarking.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringENABLED_CONSTANTBoolean BON constant that enables animation benchmarking.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddNextLabel(java.lang.String label)Queues a label to be associated with the nextAnimationBenchmark.TrackedAnimationcreated, and sets up the synchronization lock used bywait(String, long).static voidclear()Resets all benchmarking state: pending labels, completion locks, and completed animations.static Animationtrack(Animation animation)Wraps the given animation in aAnimationBenchmark.TrackedAnimationthat records timing data.static AnimationBenchmark.TrackedAnimationwait(java.lang.String label, long timeout)Blocks the calling thread until theAnimationBenchmark.TrackedAnimationregistered underlabelcompletes, or until the timeout elapses.
-
-
-
Field Detail
-
ENABLED_CONSTANT
public static final java.lang.String ENABLED_CONSTANT
Boolean BON constant that enables animation benchmarking. Iftrueand a label was queued, an animation started viaAnimatoris automatically wrapped in aAnimationBenchmark.TrackedAnimationbefore execution.Constant name: "ej.mwt.debug.animation.benchmark.enabled".
- See Also:
- Constant Field Values
-
-
Method Detail
-
track
public static Animation track(Animation animation)
Wraps the given animation in aAnimationBenchmark.TrackedAnimationthat 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.- Parameters:
animation- the animation to wrap; must not benull- Returns:
- a
AnimationBenchmark.TrackedAnimationdelegating toanimation
-
wait
public static AnimationBenchmark.TrackedAnimation wait(java.lang.String label, long timeout) throws AnimationBenchmark.AnimationTimeoutException, java.lang.InterruptedException
Blocks the calling thread until theAnimationBenchmark.TrackedAnimationregistered underlabelcompletes, or until the timeout elapses.addNextLabel(String)must be called with the same label before the animation is started, otherwise anIllegalStateExceptionis thrown.- Parameters:
label- the label of the animation to wait fortimeout- the maximum time to wait, in milliseconds- Throws:
java.lang.IllegalStateException- if called from the UI thread or no animation was registered with the given label viaaddNextLabel(String)AnimationBenchmark.AnimationTimeoutException- if the animation did not complete within the timeoutjava.lang.InterruptedException- if the calling thread is interrupted while waiting
-
addNextLabel
public static void addNextLabel(java.lang.String label)
Queues a label to be associated with the nextAnimationBenchmark.TrackedAnimationcreated, and sets up the synchronization lock used bywait(String, long).Must be called before the animation is started. Labels are consumed in FIFO order.
- Parameters:
label- the label to associate with the next benchmarked animation
-
clear
public static void clear()
Resets all benchmarking state: pending labels, completion locks, and completed animations.Call this between test runs to ensure a clean state.
-
-