I'm nailing the last bits of performance crunching on my AI, and was searching for the most efficient and fast way to provide it a good prediction routine about the movements and bounds of AI's target. Most movements are animations, so I have to write down a hard imprint of each animation bounds position (at fixed steps). Until now I was doing runtime prediction, either using Animation.Sample or just a Bezier prediction routine, but Sample is costing too much for complicated predictions, and Bezier lacks of accuracy about the bounds size. Plus, Sample() is calculating every single child tansform, which is overkill as I only need one child info (the target's hitbox).
So I chose to go the hard stored data route, and then lookup at runtime.
So I thought first about storing steps into Dictionaries, as they're the fastest lookup structure around. But then I thought back about AnimationCurve. They would save me a lot of RAM at runtime, thanks to AnimationCurve.Evaluate avoiding to have tons of entries, and I would just have to clone each bound's animation key instead of retrieving/storing its coordinates in a Dictionary (using Editor script).
"Cut the crap n0mad ! What's the question !"
---> What is the average time in miliseconds, on an average PC, to :
1) build an AnimationCurve from let's say 200 keyframes ?
2) retrieve a keyframe with Evaluate ?
or if there's not precise answer (in miliseconds), what would be the fastest between :
1) building an AnimationCurve with keyframes and building a Dictionary with new Bounds() as Values ?
2) retrieving a keyframe with Evaluate and retrieve a Dictionary Value by Key ?
The results are important only if the differences between those are more than 0.3 miliseconds (either it is for building a single AnimationCurve/Dictionary entry, or retrieving a value at runtime).