xcode 反正有没有在 OS X Mountain Lion 上读取性能计数器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13075113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there anyway to read performance counters on OS X Mountain Lion?
提问by user1775117
Shark, Apple's profiler which let you configure custom performance counters, is no longer supported in OSX Mountain Lion since it can't run a 32-bit kernel. Instruments.app, Apple's replacement for Shark, doesn't seem to support reading performance counters such as L1 cache hits/misses**. Is there anyway to actually setup and read performance counters on OS X? Even if there is no application, is there some user-land API to do this?
OSX Mountain Lion 不再支持 Apple 的分析器 Shark,它可以让您配置自定义性能计数器,因为它无法运行 32 位内核。Instruments.app,Apple 的 Shark 替代品,似乎不支持读取性能计数器,例如 L1 缓存命中/未命中**。反正有没有在 OS X 上实际设置和读取性能计数器?即使没有应用程序,是否有一些用户级 API 可以做到这一点?
**Instruments.app does seem to have an interface for performance counters, but on my Retina MacBook Pro, the PM Events window lists no events, and indicates "Device: Unknown." Are there any other alternatives to Instruments?
**Instruments.app 似乎有一个性能计数器界面,但在我的 Retina MacBook Pro 上,PM 事件窗口没有列出任何事件,并显示“设备:未知”。有没有其他乐器的替代品?
回答by justin
Yes.It's there, but difficult to find and clumsy to use (ver.4.5).
是的。它就在那里,但很难找到并且使用起来很笨拙(版本 4.5)。
- Launch Instruments.
- You are greeted by the Wizard
- Choose "Blank" template for OS X
- Press
cmd
+L
to display the Library - Add "Counters" instrument to your Instruments document
- Press
cmd
+shf
+P
-- you are presented with the PM Events floating window. - Let's evaluate "Divide Operations executed" -- Add "Divide Operations executed" to the PM Events window's search field.
- Now set the "State" of "Divide Operations executed" to "Visible"
- Now back to the main document window, press
cmd
+I
to display the info popover of the "Counters" instrument. - Press the
+
button - Set the new Counter's event to "Divide Operations executed"
- Begin sampling...
- End sampling...
- 启动仪器。
- 你受到巫师的欢迎
- 为 OS X 选择“空白”模板
- 按
cmd
+L
显示库 - 将“计数器”仪器添加到您的仪器文档中
- 按
cmd
+shf
+P
-- 您将看到 PM Events 浮动窗口。 - 让我们评估“执行的划分操作”——将“执行的划分操作”添加到 PM 事件窗口的搜索字段。
- 现在将“执行的划分操作”的“状态”设置为“可见”
- 现在回到主文档窗口,按
cmd
+I
显示“计数器”工具的信息弹出窗口。 - 按下
+
按钮 - 将新计数器的事件设置为“执行的除法操作”
- 开始采样...
- 结束采样...
You will see the results in Instruments' table columns. Of course, there are many events you could record -- So find the L1 cache events you are interested in and add them instead of divides.
您将在 Instruments 的表格列中看到结果。当然,您可以记录许多事件——所以找到您感兴趣的 L1 缓存事件并添加它们而不是分割。
Also be prepared for system freezes (one happened while writing this up).
还要为系统冻结做好准备(在写这篇文章时发生了一个)。