Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to profile memory usage of unit tests?

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?

like image 995
Rowland Shaw Avatar asked May 28 '10 15:05

Rowland Shaw


People also ask

What are two limitations of unit testing?

Limitations of Unit Testing Unit testing cannot detect integration or interfacing issues between two modules. It cannot catch complex errors in the system ranging from multiple modules. It cannot test non-functional attributes like usability, scalability, the overall performance of the system, etc.

What is a memory profiler?

The Memory Profiler is a component in the Android Profiler that helps you identify memory leaks and memory churn that can lead to stutter, freezes, and even app crashes. It shows a realtime graph of your app's memory use and lets you capture a heap dump, force garbage collections, and track memory allocations.


2 Answers

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:

When you need to simply evaluate the amount of memory allocated in a test, you can use the AssertTraffic attribute. This flexible attribute allows you to filter traffic data by object type, interface, or namespace.

like image 189
Fedor Reznik Avatar answered Sep 28 '22 09:09

Fedor Reznik


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.

like image 41
Lex Li Avatar answered Sep 28 '22 10:09

Lex Li