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.
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.
正如@Sami Laine 在他的评论中所说,Linuxperf
工具依赖于 Linux 特定代码。它依赖于非标准化的perf_event_open系统调用。
注意:也许您可以搜索 MacOSX 用户如何使用最近的硬件性能计数器。
在 macOS 上,您可以使用Instruments应用程序来分析您的代码。
我喜欢使用“时间分析器”,它会告诉你应用程序在执行过程中的各个部分有多少时间。我自己没有使用过 perf,但从我看过的谈话/视频来看,这似乎是最常见的用途。
要使用“时间分析器”:
希望这可以帮助。
在 OSX 上,您可以sample
与filtercalltree
.
如果您在没有命令的情况下运行它们,两者都有有用的帮助文本,但是在 1ms 分辨率下默认 10 秒采样进程 id 1234 的示例调用将类似于:
sample 1234 -f output.prof
filtercalltree output.prof
生成调用图后,FlameGraph是另一个可视化它的好工具,它通过脚本支持sample
调用图。stackcollpase-sample.awk
查看 Google Perf 工具
如果您没有安装 brew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
如果您安装了 brew:
brew install google-perftools