函数分析问题 - Visual Studio 2010 Ultimate [英] Function profiling woes - Visual Studio 2010 Ultimate

查看:25
本文介绍了函数分析问题 - Visual Studio 2010 Ultimate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试分析我的应用程序以监视重构前后函数的效果.我对我的应用程序进行了分析,并查看了摘要,我注意到 Hot Path 列表没有提到我使用的任何函数,它只提到了 Application.Run() 之前的函数

I am trying to profile my application to monitor the effects of a function, both before and after refactoring. I have performed an analysis of my application and having looked at the Summary I've noticed that the Hot Path list does not mention any of my functions used, it only mentions functions up to Application.Run()

我对分析还很陌生,想知道如何通过 MSDN 文档;

I'm fairly new to profiling and would like to know how I could get more information about the Hot Path as demonstrated via the MSDN documentation;

MSDN 示例:

我的结果:

我注意到在输出窗口中有很多与加载符号时失败有关的消息,其中一些在下面;

I've noticed in the Output Window there are a lot of messages relating to a failure when loading symbols, a few of them are below;

Failed to load symbols for C:Windowssystem32USP10.dll.  
Failed to load symbols for C:Windowssystem32CRYPTSP.dll.
Failed to load symbols for (Omitted)WindowsFormsApplication1inDebugSystem.Data.SQLite.dll.
Failed to load symbols for C:Windowssystem32GDI32.dll.  
Failed to load symbols for C:WindowsWinSxSx86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2comctl32.dll.
Failed to load symbols for C:Windowssystem32msvcrt.dll. 
Failed to load symbols for C:WindowsMicrosoft.NETFrameworkv4.0.30319
lssorting.dll.
Failed to load symbols for C:WindowsMicrosoft.NetassemblyGAC_32System.Datav4.0_4.0.0.0__b77a5c561934e089System.Data.dll.  Failed to load symbols for
C:WindowsMicrosoft.NetassemblyGAC_32System.Transactionsv4.0_4.0.0.0__b77a5c561934e089System.Transactions.dll.
Unable to open file to serialize symbols: Error VSP1737: File could not be opened due to sharing violation: - D:(Omitted)WindowsFormsApplication1110402.vsp

(使用代码工具格式化,因此可读)

感谢您的指点.

推荐答案

摘要视图中显示的热路径"是基于包含样本(来自函数的样本以及来自函数的样本)数量的最昂贵的调用路径由函数调用)和独占样本(仅来自函数的样本).样本"只是当分析器的驱动程序捕获堆栈时函数位于堆栈顶部的事实(这发生在非常小的时间间隔内).因此,一个函数的样本越多,它执行的就越多.

The "Hot Path" shown on the summary view is the most expensive call path based on the number of inclusive samples (samples from the function and also samples from functions called by the function) and exclusive samples (samples only from the function). A "sample" is just the fact the function was at the top of the stack when the profiler's driver captured the stack (this occurs at very small timed intervals). Thus, the more samples a function has, the more it was executing.

默认情况下,对于抽样分析,启用了名为Just My Code"的功能,该功能隐藏来自非用户模块的堆栈中的函数(它将显示 1 个非用户函数的深度如果由用户函数调用;在您的情况下 Application.Run).来自没有加载符号的模块或来自已知来自 Microsoft 的模块的函数将被排除在外.您在摘要视图上的热路径"表明最昂贵的堆栈没有分析器认为是您的代码的任何内容(除了 Main).MSDN 的示例显示了更多函数,因为 PeopleTrax.*PeopleNS.* 函数来自用户代码".单击摘要视图上的显示所有代码"链接可以关闭仅我的代码",但我不建议在此处这样做.

By default for sampling analysis, a feature called "Just My Code" is enabled that hides functions on the stack coming from non-user modules (it will show a depth of 1 non-user functions if called by a user function; in your case Application.Run). Functions coming from modules without symbols loaded or from modules known to be from Microsoft would be excluded. Your "Hot Path" on the summary view indicates that the most expensive stack didn't have anything from what the profiler considers to be your code (other than Main). The example from MSDN shows more functions because the PeopleTrax.* and PeopleNS.* functions are coming from "user code". "Just My Code" can be turned off by clicking the "Show All Code" link on the summary view, but I would not recommend doing so here.

查看摘要视图中的完成最多个人工作的函数".这将显示具有最高独占样本计数的函数,因此,根据分析方案,调用成本最高的函数.您应该在此处看到更多您的函数(或您的函数调用的函数).此外,函数"和调用树"视图可能会向您显示更多详细信息(报告顶部有一个下拉菜单,用于选择当前视图).

Take a look at the "Functions Doing The Most Individual Work" on the summary view. This displays functions that have the highest exclusive sample counts and are therefore, based on the profiling scenario, the most expensive functions to call. You should see more of your functions (or functions called by your functions) here. Additionally, the "Functions" and "Call Tree" view might show you more details (there's a drop-down at the top of the report to select the current view).

至于您的符号警告,其中大部分是预期的,因为它们是 Microsoft 模块(不包括 System.Data.SQLite.dll).虽然您不需要这些模块的符号来正确分析您的报告,但如果您在工具 -> 选项 -> 调试 -> 符号"中选中Microsoft 符号服务器"并重新打开报告,则应加载这些模块的符号.请注意,首次打开报告需要更长的时间,因为需要下载和缓存符号.

As for your symbol warnings, most of those are expected because they are Microsoft modules (not including System.Data.SQLite.dll). While you don't need the symbols for these modules to properly analyze your report, if you checked "Microsoft Symbol Servers" in "Tools -> Options -> Debugging -> Symbols" and reopened the report, the symbols for these modules should load. Note that it'll take much longer to open the report the first time because the symbols need to be downloaded and cached.

关于将符号序列化到报告文件中失败的另一个警告是文件无法写入的结果,因为它被其他阻止写入的东西打开.符号序列化是一种优化,它允许分析器在下一次分析时直接从报告文件加载符号信息.如果没有符号序列化,分析只需执行与第一次打开报表时相同的工作量.

The other warning about the failure to serialize symbols into the report file is the result of the file not being able to be written to because it is open by something else that prevents writing. Symbol serialization is an optimization that allows the profiler to load symbol information directly from the report file on the next analysis. Without symbol serialization, analysis simply needs to perform the same amount of work as when the report was opened for the first time.

最后,您可能还想在分析会话设置中尝试检测而不是采样.Instrumentation 修改您指定的模块以捕获每个函数调用的数据(请注意,这可能会导致 .vsp 文件大得多).检测非常适合关注特定代码段的时间安排,而采样则非常适合一般低开销的分析数据收集.

And finally, you may also want to try instrumentation instead of sampling in your profiling session settings. Instrumentation modifies modules that you specify to capture data on each and every function call (be aware that this can result in a much, much larger .vsp file). Instrumentation is ideal for focusing in on the timing of specific pieces of code, whereas sampling is ideal for general low-overhead profiling data collection.

这篇关于函数分析问题 - Visual Studio 2010 Ultimate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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