Shark:如何过滤到一种特定方法
我是 Shark 的新手,我想知道是否可以将时间样本缩小到一种特定的方法?
假设我想知道在调用所有 NSArray (或子类)实例的“count”方法时使用了多少资源。
I'm new to Shark, and I was wondering if it's possible to narrow down a time sample to one specific method?
Let's say I'd like to, just for the sake of it, know how much resources have been used on calls to the method 'count' for all NSArray (or subclasses) instances.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您自下而上地查看时间概况图,并向其调用者收取在库中花费的任何时间计数,那么这应该会给您带来您想要的结果。 它可以让您看到由于 -count 而花费了多少时间(即执行该方法以及该方法完成其工作所需的任何时间),还可以让您找出在哪里调用该方法。 您在 -count 上花费如此多时间的原因可能不是因为它需要很长时间,而是因为您这样做得太频繁了。
If you view the time profile graph bottom-up, and charge any time -count spends in libraries to its callers, that should give you what you want. It lets you see how much time is spent because of -count (i.e. both in executing that method, and anything the method needs to get its job done) and also lets you find out where you're calling the method. It's possible that the reason you spend so much time in -count is not because it takes long, but because you're doing it too often.
至少在功能级别上花费的时间正是 Instruments 为您提供的。 借助 DTrace,您甚至可以进行更深入的挖掘。 也许可以查看我的博客文章了解这一点。 希望这能澄清事情。
例如,您可以轻松编写 DTrace 脚本来打印 count 调用的内存消耗。
干杯,
托斯顿
The time spend at least on the function level is exactly what Instruments is giving you. With DTrace you can even dig deeper than that. Maybe checkout my blog post about this. That should hopefully clear things up.
You could easily write a DTrace script to print out the memory consumption of the count call for example.
cheers,
Torsten
您可以点击 cmd-f 来搜索符号。 确保“自动展开”复选框处于选中状态,以便它进入树中。 您可能需要打开窗口 -> 显示高级设置。
找到该符号后,右键单击它,您将看到一些选项:
焦点符号:这将让您过滤到仅对所选符号及其下方的调用
Retain Callstacks with:这将让您查看对该符号的所有调用并过滤掉其他所有内容
完成后,您可以右键单击并“取消全部焦点”或“全部恢复”。 这些命令最终会修改高级设置中的“调用堆栈数据挖掘”部分。 就这样胡闹吧。
You can hit cmd-f to search for a symbol. Make sure the "auto expand" checkbox is on so it goes down into the tree. You may need to turn on Window -> Show Advanced Settings.
Once you find the symbol, right click on it and you have some options:
Focus Symbol: this will let you filter down to just the calls to the symbol you selected and below
Retain Callstacks with: this will let you see all the calls to the symbol and filter out everything else
When you are done you can right click and "unfocus all" or "restore all". These commands end up modifying the "callstack data mining" section in the advanced settings. Fool around with that.