24

I wish to profile CPU (sample if possible), with as small a performance impact as possible (hence similar to GCC's -pg), binaries compiled with Clang. Is there an alternative that uses instrumentation of the code, or produces output similar to gprof?

Matt Joiner
  • 100,604
  • 94
  • 332
  • 495
  • You'd probably better ask that on the clang's developers list, no? – Jens Gustedt Sep 22 '10 at 13:46
  • You really want output similar to gprof? – Mike Dunlavey Sep 22 '10 at 19:04
  • 3
    Yeah why not? It's clear and comprehensive. I've never found a usable alternative, valgrind comes the closest. – Matt Joiner Sep 23 '10 at 02:34
  • These pages are full of people trying to make sense off gprof output. 1) It's *blind to blocked time*, like IO. 2) You need to train yourself to ignore "self time", it being nearly useless. 3) Similar for all the call counts and function timings. 4) No line-level info. 5) The call-graph is nice & formally interesting, and also nearly useless. I'll grant you it's usable, like a good reliable car, when you have to cross a river. – Mike Dunlavey Sep 23 '10 at 13:11
  • @Mike Dunlavey: I'm aware of 1, 2, and on 3 and 4 you are wrong. As for 5, why do you think I'm using C? gprof generates consist output, with minimal impact on performance. I've tried to find an alternative that deals with blocking time among other things without luck. gprof with its shortcomings is still superior. – Matt Joiner Sep 23 '10 at 14:21
  • For alternative tools, you might consider Zoom or LTProf. For the points above, consider points 6, 2, 3 of this: http://stackoverflow.com/questions/1777556/alternatives-to-gprof/1779343#1779343 which also points to the technique I've relied on for decades, and a thorough example where most tools today would be left in the dust, *especially* gprof and its kin. – Mike Dunlavey Sep 23 '10 at 14:44

2 Answers2

14

I received a good answer on the Clang mailing list. To summarize, the use of Google Performance Tools was the best fit.

Matt Joiner
  • 100,604
  • 94
  • 332
  • 495
2

https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-pg

now clang already support "-pg"

bluesky
  • 107
  • 7