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

前端 未结 2 983
傲寒
傲寒 2021-01-01 12:54

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 Pro

相关标签:
2条回答
  • 2021-01-01 13:08

    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.

    0 讨论(0)
  • 2021-01-01 13:16

    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.

    0 讨论(0)
提交回复
热议问题