Tuesday, December 15, 2015

Profiling Code on Mac

Today I found Instruments, a program available on the Mac OS for performing many code assessments including profiling.  I found it very easy to use.  Below are steps to profile a code.

  1. With the gnu compile suite, compile your code with the -g flag (this isn't necessary but provides a better profiling experience and you get timing down to individual lines of code)
  2. Open Instruments
  3. Select Time Profiler
  4. At the top by the red circle and pause button, select Choose target and select your code.  Provide a working directory and inputs as desired/needed.
  5. Click the red circle to begin profiling.
  6. At the bottom you should see the Call Tree filing up
  7. Double click on any item in the Call Tree to get more information