Mac OS 的 Perf stat 等价物? [英] Perf stat equivalent for Mac OS?

查看:80
本文介绍了Mac OS 的 Perf stat 等价物?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Mac OS 上是否有等效的性能统计数据?我想为 CLI 命令做同样的事情,谷歌搜索没有产生任何结果.

Is there a perf stat equivalent on Mac OS? I would like to do the same thing for a CLI command and googling is not yielding anything.

推荐答案

Mac OS X 中有 Instruments 工具来分析应用程序,包括硬件 PMU.默认是对 CPU 使用情况进行采样分析器.一些文档:https://en.wikipedia.org/wiki/Instruments_(software) https://help.apple.com/instruments/mac/current/它还具有命令行变体:https://help.apple.com/instruments/mac/current/#/devb14ffaa5

There was Instruments tool in Mac OS X to profile applications including with hardware PMU. Default is to do sampling profiler for CPU usage. Some docs: https://en.wikipedia.org/wiki/Instruments_(software) https://help.apple.com/instruments/mac/current/ It also has command line variant: https://help.apple.com/instruments/mac/current/#/devb14ffaa5

在/Applications/Utilities 中打开终端.

Open Terminal, in /Applications/Utilities.

instruments -t "Allocations" -D ~/Desktop/YourTraceFileName.trace PathToYourApp

页面https://gist.github.com/loderunner/36724cc9ee8db66db305 提及工具<代码>示例(包含在标准 Mac OS X 安装中").

Page https://gist.github.com/loderunner/36724cc9ee8db66db305 mentions tool sample ("included in a standard Mac OS X installation").

此外,旧版本的 Mac OS X(10.7 之前)和 Xcode 中提到了 Shark 工具:https://en.wikipedia.org/wiki/Apple_Developer_Tools#Shark

Also, Shark tool is mentioned for older versions of Mac OS X (before 10.7) and Xcode: https://en.wikipedia.org/wiki/Apple_Developer_Tools#Shark

使用英特尔 CPU,您可以尝试使用英特尔 Vtune 分析器 - https://software.intel.com/en-us/get-started-with-vtune-macos https://software.intel.com/en-us/vtune

With Intel CPU you can try Intel Vtune profiler - https://software.intel.com/en-us/get-started-with-vtune-macos https://software.intel.com/en-us/vtune

其他更开放的英特尔工具(部分弃用?)是 https://github.com/opcm/pcm/ 具有某种 OSX 支持.文档:https://software.intel.com/en-我们/文章/intel-performance-counter-monitor.需要自定义 MacMSRDriver 驱动程序 (kext).

Other and more open intel tool (partially deprecated?) is https://github.com/opcm/pcm/ which has some kind of OSX support. Docs: https://software.intel.com/en-us/articles/intel-performance-counter-monitor. Requires custom MacMSRDriver driver (kext).

perf stat 对事件进行计数,我不确定如何使用 Instruments 收集计数器.页 https://www.robertpieta.com/counters-in-instruments/展示了如何配置 Instruments GUI 以进行事件计数:

perf stat does counting for events, and I'm not sure how to collect counters with Instruments. Page https://www.robertpieta.com/counters-in-instruments/ shows how to configure Instruments GUI for event counting:

要配置计数器,请从 Instruments 导航菜单中选择 File -> Recording Options.出于本文的目的,将选择按时间采样.使用 + 您可以添加计数器可以计数的特定事件,这些事件在当前连接到仪器的特定 CPU 上可用.

To configure Counters, select File -> Recording Options from the Instruments navigation menu. For the purposes of this post, sampling by Time will be selected. Using the + you are able to add specific events that Counters can count available on the particular CPU currently connected to Instruments.

因此,您至少可以指示 Instruments 工具随着时间的推移定期记录计数器值.该模式报告了一些问题:http://hmijailblog.blogspot.com/2015/09/using-intels-performance-counters-on-os.html

So, you at least can instruct Instruments tool to do recording of counter values periodically over time. Some problems are reported for that mode: http://hmijailblog.blogspot.com/2015/09/using-intels-performance-counters-on-os.html

这篇关于Mac OS 的 Perf stat 等价物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆