I was profiling our gamelogic today and saw that the MonoManager update method took a lot of our frametime. I wanted to investigate which graphs are taking up how much, but that wasn’t very easy.
Reason: MonoManager uses C# events, which use a very fancy recursive call which makes looking at the call tree in the profiler very messy:
Update of three graphs:
1
2
3
4
5
6
-Invoke()
-Invoke()
-Invoke()
-UpdateGraph()
-UpdateGraph()
-UpdateGraph()
Imagine this with 300 graphs and you run out of screen real estate very quickly, not to mention actually finding a particular graph you’re looking for.
As a countermeasure, I replaced the C# events in MonoManager with UnityEngine.Events.UnityEvent, which now produces a flat call list:
1
2
3
4
-Invoke()
-UpdateGraph()
-UpdateGraph()
-UpdateGraph()
and is much easier to profile (and maybe even faster in execution?).
Maybe this would be a good change to allow better profiling out-of-the-box.
Hmm. I will take a look at this, but I’d also like to suggest an alternative for you, that being using the Unity Profiler API.
You can open up Graph.cs and change method “UpdateGraph” to be like this for example: