How do I profile parts of a function?

I have quite a long function that is taking 0.33ms according to the profiler (I presume the time is per frame?).

However, if I group my events inside the function, these groups do not show up in the profiler like they do for scene events. This is making it difficult to nail down where the performance bottleneck is.

Is there a way to get the profiler to honour groups used in functions?