如何在 Visual Studio 2008 中分析 MsTest 的单元测试?
我有从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚在 VS2008 中进行分析工作。如果它对任何人有帮助,这就是我如何让它工作:
调试
配置模式分析>;启动性能向导
分析动态链接库
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe
/testmetadata:TestList.vsmdi /runconfig:TestRunConfig1.testrunconfig
Instrumentation
。我还没有尝试过采样,所以我无法对此发表评论。使用这种方法,我确定了代码中的瓶颈,单元测试现在速度提高了 15 倍,用户看到速度提高了 10 倍。
I just got profiling working in VS2008. In case it helps anyone, here is how I got it to work:
Debug
configuration modeAnalyse > Launch Performance Wizard
Profile a dynamic link library
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe
/testmetadata:TestList.vsmdi /runconfig:TestRunConfig1.testrunconfig
Instrumentatation
. I haven't tried Sampling, so I cannot comment on that.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.
不幸的是,有序测试没有可用的“创建性能会话”选项:
如果您有一个简单的单元测试,您将能够创建一个性能会话。
要使用命令行分析,您可以导航到 \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:
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.