We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
也许您认为它太基础了,但是如果您想知道哪些代码行通过优化可以为您节省最多时间,手动堆栈采样方法非常有效。
我还建议第 2 点(例程的调用计数和时间)并不完全是您所需要的,如 这篇文章。相反,一条线在感兴趣的时间间隔内的堆栈时间百分比是直接引导您到达“瓶颈”的数字,并且不需要以高统计精度来测量它。
Maybe you consider it too basic, but if you want to know which lines of code would save you the most time by being optimized, the manual stack sampling method is very effective.
I would also suggest that point 2 (call count and time taken by routines) isn't exactly what you need, as in points 6 and 2 of this post. Rather, a line's percent-of-time-on-stack-during-the-interval-of-interest is the number that leads you straight to the "bottlenecks", and it does not need to be measured with high statistical precision.
您可以尝试下载开源分析器(VerySleepy、LukeStackWalker)并查看他们如何对应用程序进行采样,并尝试提取该逻辑。
然后,您的应用程序可以启动第二个线程,该线程除了对主线程(或所有其他线程)进行采样之外什么也不做。
请注意,为了提供可读的结果,您的应用程序应该能够直接访问该文件或通过符号服务器访问调试信息(pdb 文件)。另一种方法是将地址及其计数器转储到文件中,然后在外部实用程序中将地址转换为函数名称。
You could try to download an open source profiler (VerySleepy, LukeStackWalker) and see how they sample an application, and try to extract that logic.
Your application could then start a second thread, which does nothing more than sampling the main thread (or all the other threads).
Notice that in order to give readable results, your application should have access to the debug information (pdb file), either the file directly or via a symbol server. An alternative could be to just dump the addresses with their counters to file, and do the translation of an address to a function name in an external utility.