If you do not want to use gprof , I am not surprised .
It took me a while to figure out how to do this in GDB, but here's what I do. Launch the application and change the focus to the application output window, even if it is only a DOS field. Then I press the Control-Break key (while it's slow). Then GDB stops and I make information flows , and it tells me which flows are usually 1 and 2. I switch to the thread that I want, like thread 2 . Then I do bt to see the stack trace. This tells me exactly what he was doing when I pressed Control-Break. I do this several times, for example 10 or 20, and if there is a performance problem, no matter what it is, it is displayed on several samples of the stack. The slower he makes the program, the fewer samples I have to make before I see it.
For a complete analysis of how and why it works, see this link.
PS I also execute the SIGINT descriptor stop print nopass when starting GDB.
source share