使用仪器模型进行性能调优
如果我使用此处描述的检测模型来分析 .Net 应用程序性能,这意味着分析工具将更改要分析的可执行文件的可执行代码以插入性能测量代码? 那么我原来的可执行代码被修改了?
http://msdn.microsoft.com/en-us /library/ms242753(VS.80).aspx
问候, 乔治
If I use instrumentation model as described here to profile .Net application performance, it means the profile tool will change the executable code of the to be profiled executable to insert performance measure code? So my original executable code is modified?
http://msdn.microsoft.com/en-us/library/ms242753(VS.80).aspx
regards,
George
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的; 已检测的代码与未检测的代码不同。 这意味着您必须对结果稍微小心 - 但大多数分析器都能合理地将您的注意力吸引到重要的部分上。 我在采样选项方面从来没有什么运气——不过,仪器通常很有用。 就我个人而言,我喜欢 jetBrains 产品。
Yes; the instrumented code is different to uninstrumented code. And this means you have to be slightly careful with the results - but most profilers do a reasonable job of drawing your focus to the important bits. I've never had much luck with the sampling option - instrumentation has often been useful, though. Personally, I like the jetBrains offering.
采样模式是当您了解代码中的热点区域时,它不会修改您的代码,它只会对所有正在运行的线程的当前调用堆栈进行采样。 如果您的线程正在休眠或等待资源(互斥体、事件等),那么它将被视为热点区域。 您想使用此模式来测量负载。
仪器模式(跟踪)将测量每种方法花费的时间(以周期为单位)。
它需要检测您的代码(使用调试符号),但最终会排除它给系统带来的开销。 您想使用此模式来测量单个进程。
Sampling mode is when you what to know hot areas in your code, it doesn't modify your code it will just sample the current callstack of of all running threads. If your threads are contently sleeping or wait for a resource (mutex, event, etc) then it will count as a hot area. You want to use this mode to measure load.
Instrumnation mode (tracing) will measure how much time (in cycles) are spend in each method.
It needs to instrument your code (using the debug symbols) but it will exclude at the end the overhead that it put on the system. You want to use this mode to measure an single process.
是的,在检测时,分析器将使用附加指令来修改您的代码,以收集和跟踪必要的性能数据。 您永远不会想要分发程序集的检测版本,并且您不会希望使用检测程序集进行调试(因为关键部分/竞争条件/等在给定附加检测的情况下肯定会表现不同)。
话虽这么说,仪器对于分析要解决的目标非常有价值。 通过收集实际数据并隔离昂贵的操作,可以适当地集中优化工作并准确测量结果 - 避免浪费时间、增加复杂性、降低可维护性以及与过早优化相关的所有其他问题。
Yes, when instrumenting, the profiler is going to modify your code with additional instructions to gather and track the necessary performance data. You'd never want to distribute an instrumented version of your assemblies, and you wouldn't want to use instrumented assemblies for debugging purposes (as critical sections / race conditions / etc could certainly behave differently given the additional instrumentation).
That being said, instrumentation can be very valuable for the goals profiling is meant to address. By gathering actual data and isolating expensive operations, optimization efforts can be focused appropriately and the results can be measured accurately - avoiding wasted time, increased complexity, reduced maintanability, and all the other problems associated with premature optimization.