以编程方式插入分析标记

发布于 2024-10-04 21:41:31 字数 235 浏览 0 评论 0原文

我使用的是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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冬天旳寂寞 2024-10-11 21:41:31

您可以使用 Profiler API 以编程方式插入标记。请参阅 MSDN。

您只需从“Program Files[ x86]\Microsoft Visual Studio 9.0\Team Tools\Performance Tools”添加对 Microsoft.VisualStudio.Profiler.dll 的引用即可使用托管 API。

您的测试代码可能类似于:

MarkOperationResult result;
result = DataCollection.CommentMarkProfile(markID1, "BeginWork");
// Validate result...

SomeOperation();

result = DataCollection.CommentMarkProfile(markID2, "EndWork");
// Validate result...

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:

MarkOperationResult result;
result = DataCollection.CommentMarkProfile(markID1, "BeginWork");
// Validate result...

SomeOperation();

result = DataCollection.CommentMarkProfile(markID2, "EndWork");
// Validate result...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文