easy_profiler
easy_profiler copied to clipboard
Doesn't tracking in infinity loops
Hello, is there a way to track code blocks inside the infinity loops?
auto job = JobSystem::Scheduler::CreateJob("Test", []() { while (true) { EASY_BLOCK("Test"); Sleep(100); } }); JobSystem::Scheduler::GetInstance()->Run(job);
The code above is runned in a separated thread and EASY_BLOCK is not tracking Sleep(100). If you change loop to 'one shot' everything is fine.
need a EASY_END_BLOCK
in the loop.
because EASY_BLOCK use destructor to trigger saving, or explicit end the block
I was wrong before, the for loop triggers the destructor every time it loops. So maybe the save block is not triggered?
Hi, had a similar problem. The cause was, that the function containing the infinite loop was only finished after the dumpBlocksToFile() call occured.
To make sure the latest possible dump, try a wrapper object in your main:
class ProfilerWrapper {
public:
ProfilerWrapper() {
EASY_PROFILER_ENABLE;
profiler::startListen();
}
~ProfilerWrapper() {
profiler::dumpBlocksToFile("prof.prof");
}
};
int main(int argc, char* argv[]) {
ProfilerWrapper wp;
... do threaded work ...
}