Profiling c++ on mac os x

后端 未结 3 888
终归单人心
终归单人心 2020-12-22 16:11

I\'m attempting to profile some c++ code on my mac (os x Lion) and I haven\'t been able to find anything useful. I\'m looking for a profiler that will tell me what functions

3条回答
  •  渐次进展
    2020-12-22 16:55

    Instruments is the tool to use. A full explanation of Instruments is outside the scope of this answer, but here's a quick start guide:

    1. Open Instruments.1
    2. Select the "Time Profiler" template.
    3. Select your application in the "Target" dropdown menu.2
    4. Hit the red circle ("record") button to start your application running.
    5. If applicable, do some stuff in your application that you need to profile.
    6. Hit the record button again to stop recording.
    7. Use the tools in Instruments to analyze your results.

    Of the tools available, the ones that will be most frequently useful are:

    • Expanding the call tree using the disclosure arrows
    • Clicking the circled arrow on a function name to focus it
    • Double-clicking a function to view the associated source
    • The "Invert Call Tree" checkbox on the left-hand side

    You can also start an invocation of instruments on the command line:

    instruments -l 30000 -t Time\ Profiler -p 5773
    

    see instructions.


    1 One easy way to open Instruments is to use Spotlight: Just click on the magnifying glass in the upper right corner of the taskbar (next to the clock) and type "Instruments".

    2 Click "Choose Target..." and navigate to the path of your executable.

提交回复
热议问题