Search code examples
macosprofilingvalgrindscientific-computing

What's the easiest/best way to profile a math intensive C++ application for speed on Mac OS X?


I am devolping a console math intensive application on Mac OS X. It's implemented in C++, and I'm using no special IDE, just a plain text editor, and GCC for compiling.

Currently, my implementation is quite slow with my data. What is the easiest/best way to profile it to know which parts to optimize?

I use valgrind, at a very basic level, to check for memory leaks. However, I never used it (callgrind) for computing speed profiling. How should I do it? I find callgrind documentation a little confusing/not very newbie friendly. Is there a kcachegrind equivalent for Mac? As far as I know, Maccachegrind only works with xdebug output, and doesn't work with callgrind 3.6.0 output.

Is it better to use valgrind or gprof for profiling? I am not familiar with neither.

Thanks.


Solution

  • /Developer/Applications/Performance Tools/Shark.app
    

    Open it, run your application, hit start, let your app run for a bit, hit stop.

    There's a more detailed introduction on the Apple developer site.