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

GaTechThomas picture GaTechThomas · Apr 24, 2015 · Viewed 8.3k times · Source

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?

Answer

GaTechThomas picture GaTechThomas · Apr 24, 2015

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.