yse / easy_profiler

Lightweight profiler library for c++
MIT License
2.15k stars 184 forks source link

GUI renders blocks incorrectly if using profiler::storeBlock #149

Open inantop opened 5 years ago

inantop commented 5 years ago

I have a situation where within a larger framework I am trying to measure non-scoped durations of time -- normally an application for EASY_NONSCOPED_BLOCK. However, I can't ensure an appropriate balance between EASY_NONSCOPED_BLOCK and EASY_END_BLOCK due to the specifics of my situation.

I've implemented an alternative approach where I cache the start and end times of the events I'm interested in and later call profiler::storeBlock with the data. This correctly saves the time data to the data stream, however the GUI displays the first of these blocks as being much larger than its duration (and the Self: time is absurd, see attached photo). image

Subsequent blocks in my list of events render correctly but are occluded by the first block. Additionally, as I scroll through the timeline blocks appear and disappear.

I've obviously corrupted some assumption the GUI makes about the hierarchical structure of the blocks, but the documentation in profiler.h here: https://github.com/yse/easy_profiler/blob/develop/easy_profiler_core/include/easy/profiler.h#L514 leads me to believe that I'm not doing something absurd.

Can you clarify what might be going wrong?

inantop commented 5 years ago

I moved my storeBlock loop to a worker thread that immediately joins -- this has the blocks rendering correctly as a different thread in the GUI. This does appear to be a GUI-side problem. Is there some way for me to do this that doesn't require a thread workaround?