是否可以分析单元测试的内存使用情况?
我正在考虑使用 Visual Studio 附带的单元测试框架构建一些单元测试来确定资源是否泄漏(或没有)。
目前,我正在评估最新版本的 ANTS Profiler,但我不太清楚它是否允许我强制从代码中生成快照(这样我就可以拍摄快照,运行单元测试几百次,强制进行垃圾收集,并拍摄另一个快照,并将结果保存起来以供以后分析)。
这是否可以与 ANTS/Visual Studio 相关,还是我应该使用其他分析器探索选项?
I'm looking at building some unit tests to ascertain if resources are leaking (or not) using the unit testing framework that comes with Visual Studio.
At present, I'm evaluating the latest version of ANTS Profiler, but I can't quite work out if it allows me to force a snapshot from code (so that I can take a snapshot, run a unit test a few hundred times, force a garbage collection, and take another snapshot, and save the results out for later analysis).
Is this possible to do with ANTS/Visual Studio or should I be exploring options with other profilers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您看过 JetBrains 的 dotmemory 吗?
dotMemory Unit 是一个单元测试框架,允许您编写测试
检查您的代码是否存在各种内存问题。
例如:
Have you seen dotmemory from JetBrains?
dotMemory Unit is a unit testing framework which allows you to write tests
that check your code for all kinds of memory issues.
For example:
JetBrains dotTrace/dotMemory 和 ReSharper 在单元测试和分析方面有更好的集成。
http://www.jetbrains.com/profiler/index.html
不确定是否ANTS有这样的集成,不过你可以咨询一下红门售前吧?
http://www.red-gate.com/about/all_testimonials.htm
他们确实希望您致电他们以获取更多信息。
JetBrains dotTrace/dotMemory and ReSharper have better integration on unit testing and profiling.
http://www.jetbrains.com/profiler/index.html
Not sure if ANTS has such integration, but you can consult Red Gate presales, right?
http://www.red-gate.com/about/all_testimonials.htm
They do expect you to call them for more information.
我使用 ANTS 探查器,我发现最方便的是将探查器附加到正在运行的测试进程,这可能会有所不同,具体取决于您使用的测试框架。例如,我使用 Resharper,进程映像名称类似于:
JetBrains.ReSharper.TaskRunner.CLR...
I use ANTS profiler, and what I find most convenient is to attach the profiler to the running test process, that may be different depending on what testing framework you are using. For example, I use Resharper and the process image name is called something like:
JetBrains.ReSharper.TaskRunner.CLR...
对于未来的读者,值得一提的是,您可以使用 ANTS Memory Profiler 从代码中强制执行快照。您需要引用
RedGate.MemoryProfiler.Snapshot.dll
ANTS 安装目录中包含的 。然后,您可以通过调用
RedGate.MemoryProfiler.Snapshot.TakeSnapshot("Optional snapshot name")
来拍摄快照完整详情请参见此处。
For future readers, worth mentioning that you can force snapshots from within your code with ANTS Memory Profiler. You need to reference
RedGate.MemoryProfiler.Snapshot.dll
which is included in the ANTS install directory. You can then take a snapshot by calling
RedGate.MemoryProfiler.Snapshot.TakeSnapshot("Optional snapshot name")
Full details here.