Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a useable command line profiling tool on OS X?

Tags:

macos

I wanna use something like gprof to profile C/C++ programs on command line. But unfortunately gprof doesn't work on OS X for some reason (that's a known issue).

When I search this topic on internet, almost everyone recommends Instruments.app. As my workflow is entirely in command-line environment, I really don't want to switch to GUI just for some profiling.

So is there currently a usable alternative to gprof on OS X, which is purely command line based?

Edit: More specifically, I want to use the tool to analyze the runtime of each function in my program, to find out the hotspots.

like image 948
lei_z Avatar asked Aug 15 '15 01:08

lei_z


1 Answers

There's a command line tool component of Instruments: the instruments command. You typically will want to use Instruments.app to view the resulting trace, though.

Besides that, there are lots of different tools. There's sample for simple time profiling. There's spindump. There's DTrace and a whole suite of ready-made DTrace-based tools. (See man -k dtrace for a list.)

You'll need to be more specific about what exactly you're hoping to investigate about your programs to a get a more specific suggestion.

like image 150
Ken Thomases Avatar answered Sep 23 '22 07:09

Ken Thomases