tags:

views:

165

answers:

2

My standard Linux way of profiling app is:

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

Apparently gprof is broek on MacOSX 10.5, and I am supposed to use Shark. All the tutorials I've found aby Shark involves XCode (whereas my build is done with Makefiels and g++).

Can someone post step by step instructions for using shark on an app 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?
+1  A: 

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

You really don't need to use Xcode to build an app for profiling under Shark - I have command line tools built with Makefiles that I profile with Shark all the time. You can either trigger Shark automatically from within your code (there are a couple of different APIs for this) or you can use the "chudRemoteCtrl" command line tool (man chudRemoteCtrl) or you can just configure the Launch options in Shark to set the executable path, working directory, command line arguments, etc, and away you go. Make sure you build your app with -g so that Shark can display source code rather than disassembled object code.

Shark configuration for command line tool

Paul R
+1  A: 

Here's a relevant thread

Unfortunately, I don't know how to do this at the command line on Mac OS X, and I'm running 10.6... i usually let the Xcode magic take over :-S

Robert Karl