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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With