Reputation: 2604
I need the "perf" utility to monitor the program on my Mac. I know linux comes with it, but is it available on Mac?
I am working on a OSX 10.9 Mavericks and tried "port search" for perf or linux-tools, but I couldn't get any results.
Upvotes: 66
Views: 59193
Reputation: 3097
On OSX you can use sample
together with filtercalltree
.
Both have useful help text if you run them without commands, but an example invocation to sample process id 1234 for the default 10 seconds at 1ms resolution would be something like:
sample 1234 -f output.prof
Once you've generated your call graph, FlameGraph is another great tool for visualizing it, and it supports sample
call graphs via the stackcollpase-sample.awk
script:
filtercalltree output.prof | ./stackcollapse-sample.awk output.prof | ./flamegraph.pl kernel.svg
Upvotes: 21
Reputation: 41
Check out Google Perf Tool
If you dont have brew installed:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
If you have brew installed:
brew install gperftools
Reference: https://github.com/gperftools/gperftools
Upvotes: 4
Reputation: 2077
On macOS you can use the Instruments application to profile your code.
I like to use the "Time Profiler" which will show you how much time your application is its various parts during execution. I haven't used perf myself, but from talks/videos that I've seen this seems to be the most common use.
To use the "Time Profiler":
Hope this helps.
Upvotes: 36
Reputation: 19050
As @Sami Laine said in his comment, the Linux perf
tool is dependent on Linux specific code. It relies on the perf_event_open system call which is not standardized.
Note: Maybe you could search how MacOSX users are using recent hardware performance counters.
Upvotes: 41