C ++ profiling on mac os x

I am trying to profile some C ++ code on my mac (os x Lion) and I could not find anything useful. I am looking for a profiler that will tell me which functions are taking up my processor time (similar to the Matlab profiler).

Here is what I tried

  • other. This is what I use on my Linux machine, but it just gives me empty output on my mac (apparently a known issue).
  • Instruments. I can’t understand for my whole life how to profile anything in my compiled binary. I also cannot find any useful tutorial.
  • (in another search, a shark was found that is no longer available, and Valgrind for memory).

Really appreciate the help!

+44
profiling macos
Jul 12 2018-12-12T00:
source share
3 answers

Tools are a tool to use. A full explanation of the tools is beyond the scope of this answer, but here is a quick guide:

  • Open tools. one
  • Select the Time Profiler template.
  • Select your application from the "Target" drop-down menu. 2
  • Press the red circle button (“record”) to launch the application.
  • If applicable, do some of the things in your application that you need for your profile.
  • Press the record button again to stop recording.
  • Use the tools in the Tools to analyze your results.

Of the available tools, the following will be most useful:

  • Extending the call tree with the expansion arrows
  • Click a circular arrow on a function name to focus it
  • Double click function to view related source
  • The "Invert call name" checkbox on the left



1 One easy way to open tools is to use Spotlight: just click on the magnifying glass in the upper right corner of the taskbar (next to the clock) and enter "Tools". Sub>

2 Click "Select Target ..." and browse to the path to the executable file.

+77
Jul 12 2018-12-12T00:
source share

Tools is the right answer, but if you cannot figure out how to use it, then another option is the profiler of the built-in Activity Monitor application. In Activity Monitor you can get information about any running process and there is a button to try to execute it for a while. You will need to run your program, switch to Activity Monitor, find the process and then try it.

In addition, you can "profile a bad person" simply by running the program in the debugger and manually suspending it half a dozen times or so and marking the call stack at that time. It is very simple, but it works surprisingly well, as a first pass for a large part of the programs.

+5
Mar 15 '13 at 20:01
source share

Tools are a tool to use. To overcome the problem of empty traces, make sure that you open Tools from Xcode:

Xcode > Open Developer Tool > Instruments 

If you open the Tools from the icon of the old tool that you tied to the dock until the last upgrade to Xcode, it will give you empty tracks.

+4
Dec 04 '14 at 23:01
source share



All Articles