easy_profiler icon indicating copy to clipboard operation
easy_profiler copied to clipboard

Doesn't tracking in infinity loops

Open aantropov opened this issue 2 years ago • 2 comments

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.

aantropov avatar Sep 30 '21 20:09 aantropov

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?

daohu527 avatar Feb 23 '23 15:02 daohu527

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 ...

}

fk-bbraun avatar Jun 28 '23 13:06 fk-bbraun