以编程方式插入分析标记
我使用的是Visual Studio 2008开发版的Profiler。为了执行“有针对性的分析”,我可以在附加到当前运行的测试代码时通过“标记”手动设置分析器过滤器。但我想以编程方式插入标记。我想向我的测试代码添加一个调用、指令或指令,当执行时,它会告诉探查器“这是一个名为“BeginWork”的“标记””和“这是一个名为“EndWork”的“标记””。
有办法做到这一点吗?如果没有,Visual Studio 2010有这个能力吗?
I'm using the Profiler of Visual Studio 2008 Development Edition. To perform "targeted profiling," I can manually set profiler filters through "marks" anytime I am attached to my currently-running test code. But I would like to insert the marks programmatically instead. I would like to add a call, instruction, or directive to my test code that, when executed, tells the profiler "this is a 'mark' called 'BeginWork'" and "this is a 'mark' called 'EndWork'".
Is there a way to do that? If not, does Visual Studio 2010 have that ability?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Profiler API 以编程方式插入标记。请参阅 MSDN。
您只需从“Program Files[ x86]\Microsoft Visual Studio 9.0\Team Tools\Performance Tools”添加对 Microsoft.VisualStudio.Profiler.dll 的引用即可使用托管 API。
您的测试代码可能类似于:
You can use the Profiler API to insert marks programmatically. See the DataCollection.CommentMarkProfile method documentation on MSDN.
You just need to add a reference to Microsoft.VisualStudio.Profiler.dll from 'Program Files[ x86]\Microsoft Visual Studio 9.0\Team Tools\Performance Tools' to use the managed API.
Your test code could look something like: