Partial profiling on Linux

I have a program in which considerable time is spent downloading and saving data. Now I want to know how much time each function takes as a percentage of the total time. However, I want to exclude the time taken to load and save functions from the total time considered by the profiler. Is there a way to do this with gprof or any other popular profiler?

+6
source share
4 answers

Similarly you can use

valgrind --tool=callgrind --collect-atstart=no --toggle-collect=<function> 

Other viewing options:

 --instr-atstart # to avoid runtime overhead while not profiling 

To get information about the level of training:

 --collect-jumps=yes --dump-instr=yes 

Alternatively, you can "remotely control" it on the fly: callgrind_control or annotate the source code (IIRC also with branch forecast statistics): callgrind_annotate .

Great tool kcachegrind is a great visual / navigation tool . I can hardly recommend it enough:

enter image description here

+11
source

I would like to use more modern than gprof , like OProfile . When creating a report using opreport you can use the --exclude-symbols parameter to exclude functions that you are not interested in.

See the OProfile webpage for more information; however, for a quick start guide, see the OProfile docs page.

+5
source

RotateRight Zoom offers a system-wide time profile for Linux. If your code spends a lot of time on input-output, then this time will not be displayed in the temporary CPU profile. Also, if you want to take into account the time spent on I / O, try the "flow time profile".

+2
source

for a simple basic solution, you may need the log data in a csv file.

eg. Format [functionKey, timeStamp \ n]

... then load it into Excel. Get the delta and then enable or exclude based on if functions. Nothing special. On the other hand, you can get some visualizations pretty cheaply.

0
source

Source: https://habr.com/ru/post/892275/


All Articles