How to profile performance for a single unit test using Visual Studio 2013 Professional?

这一生的挚爱 提交于 2019-12-18 14:01:03

问题


I would like to run the Visual Studio 2013 Professional edition profiler for a single automated test. It is not clear from other questions here on how to do so using the Professional edition.

Is this possible and if so, how?


回答1:


Ok, so I figured out how to do it for profiler sampling (not instrumentation)...

  1. Launch Visual Studio (VS) and open the project that has the automated test that you would like to profile.
  2. Put a breakpoint on the first line of the test that will be profiled.
  3. Debug the test.
  4. Start a second instance of VS.
  5. Open Performance Explorer (depending on your version of VS2013 this will be at either Tools->Analyze->Windows->Performance Explorer or Analyze->Windows->Performance Explorer).
  6. In Performance Explorer, click Actions->Attach and attach to vstest.executionengine.*.
  7. Go back to the first VS instance (currently at a breakpoint) and run the test to completion.
  8. Go back to the second VS instance. The profiler will detect that the unit test process has exited and complete its profiling.

One thing that could be improved would be to do this with instrumentation, but it is not currently clear to me how that could be done in VS Professional edition.




回答2:


To run performance analysis on a unit test, I just create a console application that I call the unit test method from, then use that as the target project for the performance analysis. This is probably easier than firing up two instances of VS and attaching.



来源:https://stackoverflow.com/questions/29855085/how-to-profile-performance-for-a-single-unit-test-using-visual-studio-2013-profe

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