如何在 Visual Studio 2008 中分析 MsTest 的单元测试?

发布于 2024-10-04 20:19:17 字数 415 浏览 0 评论 0原文

我有从 Visual Studio 2008 Development Edition 启动的集成测试(它们作为 MSTest 单元测试执行,即使它们实际上是集成测试)。我想在测试进行时进行一些分析。

就我而言,我正在运行 MSTest“有序”测试。我想在执行每个有序测试时收集采样数据。

我该怎么做?

ps 也许我可以从命令行完成此操作,如果我从命令提示符手动启动 mstest,同时尝试遵循 命令行说明。不幸的是,当我尝试从 Visual Studio 命令提示符启动 VsPerfCLREnv 时,显示“找不到文件”。到底是什么?

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?

p.s. 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮光之海 2024-10-11 20:19:17

我刚刚在 VS2008 中进行分析工作。如果它对任何人有帮助,这就是我如何让它工作:

  1. 确保您处于调试配置模式
  2. 单击分析>;启动性能向导
  3. 选择分析动态链接库
  4. 输入以下内容:
    • Dll 路径:您要检测的 dll,位于单元测试项目的 bin\Debug 中
    • 可执行路径:C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe
    • 启动选项参数:/testmetadata:TestList.vsmdi /runco​​nfig:TestRunConfig1.testrunco​​nfig
      • 根据您的 vsmdi 和 testrunco​​nfig 文件的名称进行调整。
    • 工作目录:您的解决方案根路径
  5. 选择Instrumentation。我还没有尝试过采样,所以我无法对此发表评论。
  6. 运行新的性能项目

使用这种方法,我确定了代码中的瓶颈,单元测试现在速度提高了 15 倍,用户看到速度提高了 10 倍。

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.

找回味觉 2024-10-11 20:19:17

不幸的是,有序测试没有可用的“创建性能会话”选项:
Ordered Tests

如果您有一个简单的单元测试,您将能够创建一个性能会话。

要使用命令行分析,您可以导航到 \Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools,您将在其中看到 vsperfclrenv.cmd 和分析器博客中提到的其他工具。

Unfortunately Ordered Tests don't have the 'Create Performance Session' option available:
Ordered Tests

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文