如何分析只是一个类库? [英] How to profile only a class library?

查看:182
本文介绍了如何分析只是一个类库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要分析它编译成VS2012 DLL中的类库项目的CPU使用率

I want to profile the CPU usage of a class library project which is compiled into a dll with VS2012.

当我进入分析 - >启动性能向导,我可以选择需要分析哪些项目,但它只是让我配置文件的可执行文件,所以我不能分析我的图书馆。

When I go into Analyze -> Launch Performance Wizard, I can choose which project to profile but it only lets me profile executables, so I can't profile my library.

如果我简介我的两个项目(一个是我真的不 - 从我的图书馆运行的功能,并显示一些输出),那么 System.Windows.Forms.Application.Run 占用了我的样本的97%,非常简单的形式在乎的表现形式成本,它压倒一切。

If I profile both of my projects (one is a very simple Form which runs functions from my library and shows some output) then System.Windows.Forms.Application.Run takes up 97% of my samples - I don't really care about the performance cost of the form, and it overwhelms everything else.

我如何可以看到刚才我的DLL的性能数据?

How can I see the performance data for just my dll?

推荐答案

您需要创建一个单元测试,行使不同的库函数你感兴趣的分析。

You need to create a unit test which exercises the various library functions you are interested in profiling.

然后,您可以右键点击该测试中的测试资源管理器,然后选择配置文件测试

You can then right click on the test in the "Test Explorer" and then select "Profile Test".

这应与选择的测试揭开序幕性能分析会话。我不知道他们为什么躲在这个非常有用的功能这么好!

This should kick off a performance analysis session for the selected test. I not sure why they hid this very useful feature so well!

在VS2012中,此选项可能是灰色的。在这种情况下,你可以通过删除你的%LOCALAPPDATA%\Microsoft\VisualStudio\11.0\ComponentModelCache 文件夹,并重新启动Visual Studio中启用它。 (的来源

In VS2012, this option may be grayed out. In this case you can enable it by deleting your %localappdata%\Microsoft\VisualStudio\11.0\ComponentModelCache folder and restarting Visual Studio. (source)

这篇关于如何分析只是一个类库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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