Skip to main content

Baseline: Two state toggle

For our baseline, we are going to look at the simple 2 state toggle.

image.pngThe default toggle we will be comparing against. Two animations, each with two frames, both with the same value. Write defaults on.

In every layer count test, the graph for layers vs frame time is quadratic. this means that the more layers you have, the worse adding an extra layer becomes. However, the quadratic term isn’t very strong, so for low layer counts, it can be approximated by a linear graph. For the basic toggle, this will be 0.01 ms per layer. This is our baseline to compare against.

image.pngThe frame time to layer count graph for the basic toggle without being actively toggled.

If we run this same benchmark again, but while actively animating the layers, we get the following graph.

image.pngThe frame time to layer count graph for the basic toggle while being actively toggled. 

This graph shows us that there is an approximately 20-30% higher cost for toggles that are constantly toggled, compared to ones that aren’t. This would be the case for face/eye tracking for example. This 20-30% higher cost seems to be consistent with all my setups (AnyState, AnyState self transition, multiple animators, etc.), except for direct Blend Trees, where it depends on the setup.