1

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.

Ricardo Sanchez-Saez
  • 9,466
  • 8
  • 53
  • 92
  • 1
    Can you use GDB? Then this works: http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024 – Mike Dunlavey Nov 18 '10 at 12:12

2 Answers2

3
/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.

Stephen Canon
  • 103,815
  • 19
  • 183
  • 269
2

You should be able to install kcachegrind from Macports (package kdesdk4) and maybe also fink (which I never used myself) and use it just as you do on Linux. I did that in the past and it worked fine.

Frank Osterfeld
  • 24,815
  • 5
  • 58
  • 70