How to profile only a class library?

て烟熏妆下的殇ゞ 提交于 2019-12-22 06:36:51

问题


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.

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.

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


回答1:


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!

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)



来源:https://stackoverflow.com/questions/13240084/how-to-profile-only-a-class-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!