简体   繁体   中英

How to Profile Unit Tests of MsTest in Visual Studio 2008?

I've got integration tests which I launch from Visual Studio 2008 Development Edition (they are executed as MSTest unit-tests, even though they are actually integration tests). I would like to do some profiling while the tests are being carried out.

In my case, I have an MSTest "ordered" test I'm running. I'd like to collect sampling data while each of the ordered tests is executed.

How do I do this?

ps Perhaps I can accomplish this from the command line, if I manually launch mstest from a command prompt, while trying to follow command line directions . Unfortunately, when I try to launch VsPerfCLREnv from the Visual Studio command prompt, it is "file not found." What the heck?

I just got profiling working in VS2008. In case it helps anyone, here is how I got it to work:

  1. Ensure you are in Debug configuration mode
  2. Click Analyse > Launch Performance Wizard
  3. Select Profile a dynamic link library
  4. Enter the following:
    • Dll path: The dll you want to instrument, located in the bin\\Debug of your unit test project
    • Executable path: C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\MSTest.exe
    • Start Option Arguments: /testmetadata:TestList.vsmdi /runconfig:TestRunConfig1.testrunconfig
      • Adjust this based on the name of your vsmdi and testrunconfig files.
    • Working directory: Your solution root path
  5. Choose Instrumentatation . I haven't tried Sampling, so I cannot comment on that.
  6. Run the new performance project

Using this approach I identified the bottleneck in my code, and the unit tests are now 15x faster, and the users are seeing a 10x speed improvement.

Unfortunately Ordered Tests don't have the 'Create Performance Session' option available: 有序测试

If you had a simple unit test you would be able to create a performance session.

To use command-line profiling you can navigate to \\Program Files\\Microsoft Visual Studio 9.0\\Team Tools\\Performance Tools where you will see vsperfclrenv.cmd and other tools mentioned on the profiler blog.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM