3

I am new to Mac OSX, and I wonder if Xcode can generate , for a given C++ source code, the call graph of the program in a visual way.

I also wonder if for each function, and after a run, whether it can also print the %time spent on the function

If so, I would thank really some links with tutorials or info, after googling I did not find anything relevant

Thanks

Open the way
  • 26,225
  • 51
  • 142
  • 196
  • 1
    I think there is a difference between a callgraph and profiling: As far as I understand a callgraph helps you understanding what the program does (eg which method calls which other methods and so on). A callgraph can be drawn from static code analysis (doxygen can do this) A profiler profiles the program at runtime and tells you how much time the cpu spent on a certain function. This is something different. – Nils May 05 '10 at 06:55
  • I agree. This should be two separate questions. – Raffi Khatchadourian Jun 22 '11 at 22:02
  • Hi, can anyone explain this step: A callgraph can be drawn from static code analysis (doxygen can do this). I am installing Doxygen and try to get a call graph for an Objective-c project within Xcode. – ramo Jul 02 '14 at 02:33
  • See here for how to get clang to generate a call graph it for you. http://stackoverflow.com/questions/5373714/generate-calling-graph-for-c-code – Jason Jul 17 '15 at 00:37

2 Answers2

0

I'm not sure about drawing a call graph but for profiling you should look for Shark, which is part of the XCode developer bundle. Check out developer.apple.com/mac for documentation.

High Performance Mark
  • 77,191
  • 7
  • 105
  • 161
0

Use Run->Run With Performance Tool->Time Profiler to launch the app in Instruments.app. Instruments uses Dtrace under the hood and provides a huge wealth of profiling and measurement tools. The Time Profiler template will get you time profile and call stacks, but I don't think there is any way to get a call graph for the entire execution (though there's so much in Instruments, I may easily be wrong).

Shark is an older profiling tool from Apple and provides some very nice optimization hints. In general, you should start with Instruments and use Shark only if needed for optimizing.

Barry Wark
  • 107,306
  • 24
  • 181
  • 206