G ++ profiling - MacOSX applications?

My standard way of profiling Linux is:

1) compile with g++ -pg 2) run prog 3) gprof 

Obviously, gprof is squeamish on MacOSX 10.5, and I have to use Shark. All the tutorials I found in Shark include Xcode (while my build is done using Makefiels and g ++).

Can someone post step-by-step instructions on using a shark in an application built with g ++? Say something like:

 int main() { while(1); } g++ blah.cpp -o blah; do I need to give it more command line arguments? how do I use shark here? 
+7
g ++ macos shark
source share
2 answers

Instrumental profiling, such as gprof, is not particularly useful if you really just don't want to know about call graphs and the number of times these functions are called. Much more useful for performance analysis is the sampling profiler, and this Apple Shark tool (part of the CHUD) is one of the best.

You really don't need to use Xcode to create a profiling application in Shark - I have command line tools created using the Makefile that I constantly profile with Shark. You can either automatically activate Shark from your code (there are several different APIs for this), or you can use the command-line tool "chudRemoteCtrl" ( man chudRemoteCtrl ), or you can simply configure the startup parameters in Shark to set the executable path, working directory , command line arguments, etc., and you leave. Make sure you create an application with -g so that Shark can display the source code rather than the disassembled object code.

Acoustic configuration for the command line tool http://www.freeimagehosting.net/uploads/386737a1fa.jpg

+3
source share

Here is the corresponding thread

Unfortunately, I don’t know how to do this on the command line on Mac OS X, and I run 10.6 ... I usually allow Xcode magic: -S

+1
source share

All Articles