A bit confused here by the CPU profiler in the Unreal Frontend application. See the following image of my Event Graph showing averages over a number of frames:
Right, so my understanding is:
Inclusive Time is the amount of time spent in a function and all child functions, i.e. the time from start of the function up until it’s return.
Exclusive Time is the amount of time spent purely in that function, excluding time spent in child functions.
Now that’s fine, but why is the average Exclusive Time greater than the Inclusive Time for ‘Overall AI Time’ (highlighted) in this case? Hopefully somebody can explain this to me!
One possible explanation would be that this function is called by more than one parent caller so it is possible that the time spent exclusively inside it is longer than the time spent inclusively into the caller highlighted from this call stack.
This said, although this hypothesis is reasonable for regular functions, it does not explain why some Tick functions do exhibit similar discrepancies. Since they are very likely to always be called by the same caller one would expect them to not exhibit this behavior but some do…
Okay, so here’s what I could figure out by a little bit of experimentation:
First, you have to differentiate if you have a single frame selected or multiple.
For a single selected frame:
Inclusive time tells you the total amount of time spent in this function in this frame, across every call to this function and including child function calls.
Exclusive time doesn’t tell you anything, but you can still get the exclusive time by looking at the inclusive time of Self.
For multiple selected frames:
Inclusive time tells you the average amount of time spent in this function across all selected frames. This average takes into account all calls to this function and child function calls from each selected frame.
Exclusive time tells you the total amount of time spent in this function across all selected frames, excluding child function calls. You can get the average exclusive time by looking at the inclusive time of Self (You’ll notice that the Exclusive Time(%) is the same as the Inclusive Time(%) of Self(*)).
I was very annoyed that this just isn’t explained anywhere, so I hope this clears things up.
(*) The percentages only match if all events are shown, as the Inclusive Time(%) is adjusted when you filter events to always add up to 100% of the calling function.