- Home /
Profiler.BeginSample doesn't seem to work in CoRoutine?
Unity 5.3.3f, Windows x64, Visual Studio 2015 Community, all targets, running on Windows 7 x64.
Hi. In the process of trying to measure performance of various parts of the code I've added some BeginProfiler("label") calls in some subroutines which I suspect are generating an amount of garbage.
An example is:
Profiler.BeginSample("frequentUpdate");
while (_timer > 0 && !_exitTest)
{
// does some things I know to be GC heavy including string manipulation
// does some more stuff
yield return new WaitForEndOfFrame();
}
Profiler.EndSample();
And I see nothing relating to this tag in the active profiler window. I have made sure that my profiler frame pointer is on a frame where this is executing, but still nada.
I'm thinking that either,
a) tagged samples don't work in a coroutine, or b) the yield clause to the Enumerator is causing this to break
But the documentation isn't showing me anything helpful, neither is Google.
Anyone got an actual answer?
Thanks
I'm wondering this too. I would imagine you have to do something like:
Profiler.BeginSample("frequentUpdate");
while (_timer > 0 && !_exitTest)
{
// does some things I know to be GC heavy including string manipulation
// does some more stuff
Profiler.EndSample();
yield return new WaitForEndOfFrame();
Profiler.BeginSample("frequentUpdate");
}
Profiler.EndSample();
Your answer
![](https://koobas.hobune.stream/wayback/20220612072011im_/https://answers.unity.com/themes/thub/images/avi.jpg)