1

for a while I have been using gprof to profile my C code but it is very very unstable, on every run it is giving me a different simulation time as well as %. I have decided to switch to valgrind, I am profiling using the valgrind, however I want to display the data and get similar results to gprof. In gprof I got the % execution time, self ns/call

Is there a way to get this info without using kcachegrind?

Kcachegrind is opening the UI, and I prefer to get files so i can analyze, as I want to do several profilings together

Thanks for the help

Syntax_Error
  • 5,964
  • 15
  • 53
  • 73
  • What kind of code are you profiling? Application code or library code? Is there any I/O in it? Is there recursion? Regardless, have you tried Zoom from RotateRight.com? – Mike Dunlavey Jul 11 '11 at 15:03
  • Im after some free ware for the moment zoom has 30 day trial. – Syntax_Error Jul 11 '11 at 15:09
  • 2
    Well, [this method](http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024) is free and it works, though it runs contrary to gprof-style [general wisdom](http://stackoverflow.com/questions/1777556/alternatives-to-gprof/1779343#1779343). The reason for asking what you're profiling is gprof is only useful for a very narrow kind of program - CPU-bound, not many calls, no recursion, etc. – Mike Dunlavey Jul 11 '11 at 15:17
  • looks good, will try it incase valgrind doesnt work! thanks =) – Syntax_Error Jul 11 '11 at 15:51
  • It's based on the idea that heavy statements naturally expose themselves to random snapshots, without you having to actually measure them. In the limit, you can find an infinite loop in one shot. – Mike Dunlavey Jul 11 '11 at 16:44

1 Answers1

1

So if you want to use bare data, why are you looking at the gui? Start from the lower level, the cachegrind itself. http://valgrind.org/docs/manual/cg-manual.html

MK.
  • 33,605
  • 18
  • 74
  • 111
  • I am not looking at the GUI, but to get the results KCachegrind uses a GUI. I am looking for the command that would display such info in the command window – Syntax_Error Jul 11 '11 at 15:10
  • @Syntax_Error what I'm trying to say is that KCachegrind is just a gui layer on top of Cachegrind, so solution to your problem likely lies in using Cachegrind, not KCachegrind. – MK. Jul 11 '11 at 16:49
  • 1
    the tool is callgrind, btw (cachegrind is actually another one). It dumps the results to a file, which you then open in kcachegrind. All you can do on the CLI is to control dumping snapshots, zeroing counters, start/stop instrumentation etc. using callgrind_control, and reading the files created by dumping counters. Reading the latter manually is rather futile, IMO, and using a GUI like kcachegrind to open them is as good as it gets. You can of course collect those files while running callgrind on the CLI and later open and analyze them in kcachegrind. – Frank Osterfeld Jul 11 '11 at 17:39