Identifying performance "bottlenecks" with Do-It-Yourself performance profiling
Optimization principal 4: Use performance data to drive design and coding decisions.
The Unity 5 performance profiler is great, but there may be times where we wish to have completed control over the code we are running and how it displays or logs data. In this recipe, we explore how to use a freely available script for DIY performance profiling. While it's not quite as fancy as the graphical and detailed profiling of the performance profiler from Unity, it still provides low-level data about the time required for each frame by named parts of scripts, which is sufficient for making code design decisions to improve game performance.
Getting ready
For this recipe, we have provided C# script Profile.cs
in the 1362_11_14
folder. This is the DIY profiling script from Michael Garforth, kindly published under Creative Commons on the Unify Wiki at http://wiki.unity3d.com/index.php/Profiler.