开发者

Profiling partial programs in Linux

I开发者_JAVA百科 have a program in which significant amount of time is spent loading and saving data. Now I want to know how much time each function is taking in terms of percentage of the total running time. However, I want to exclude the time taken by loading and saving functions from the total time considered by the profiler. Is there any way to do so using gprof or any other popular profiler?


Similarly you can use

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

Other options to look at:

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

To get instructionlevel stats:

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

Alternatively you can 'remote control' it on the fly: callgrind_control or annotate your source code (IIRC also with branch predictions stats): callgrind_annotate.

The excellent tool kcachegrind is a marvellous visualization/navigation tool. I can hardly recommend it enough:

Profiling partial programs in Linux


I would consider using something more modern than gprof, such as OProfile. When generating a report using opreport you can use the --exclude-symbols option to exclude functions you are not interested in.

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


Zoom from RotateRight offers a system-wide time profile for Linux. If your code spends a lot of time in i/o, then that time won't show up in a time profile of the CPUs. Alternatively, if you want to account for time spent in i/o, try the "thread time profile".


for a simple, basic solution, you might want log data to a csv file.

e.g. Format [functionKey,timeStamp\n]

... then load that up in Excel. Get the deltas, and then include or exclude based on if functions. Nothing fancy. On the upside, you could get some visualisations fairly cheaply.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜