Make profiling a part of continuous integration (.NET)
If you’re a .NET developer who doesn’t follow our ReSharper Ultimate blog, then you probably missed a couple of blog posts about two new cool features in our dotTrace and dotMemory .NET profilers. Why are we writing about them in the TeamCity blog? Because these features are closely related with TeamCity and CI in general: they allow you to make performance and memory profiling a part of your continuous integration builds. So what is this hype all about?
Performance profiling in CI
Let’s begin with dotTrace and performance profiling. Along with dotTrace 6.2, we released a dotTrace Plugin to TeamCity. It allows you to prevent application performance regression by profiling your integration tests. The workflow is pretty simple:
- Write an integration test that runs some performance-critical functionality in your application.
- In the plugin, set a performance threshold for this test, which is the execution time value in ms or value taken from previous successful builds.
Now, if the test exceeds its threshold, the plugin will fail the build and save the collected performance snapshot to build artifacts.
- Open the snapshot in dotTrace and find the exact cause of the performance issue.
More details on the plugin are available in this post.
Memory profiling in CI
Not so long time ago we released dotMemory Unit – an additional unit testing framework that allows you to write tests that check your code for all kinds of memory issues, including memory leaks, high memory traffic, etc. For example, here’s how easy it is to check memory for objects of some
Foo type with an NUnit test:
dotMemory.Check(memory => Assert.That( memory.GetObjects(where => where.Type.Is<Foo>()).ObjectsCount, Is.EqualTo(0));
Now the time has come for the dotMemory Unit standalone launcher that can be used in CI. For TeamCity users, we have something even better: a dotMemory Unit plugin. This plugin adds the support for dotMemory Unit to all TeamCity .NET test runner types. This means you can run tests that use dotMemory Unit along with other tests on your CI server.
For more information on the dotMemory Unit plugin, please see this blog post.
You’re welcome to give the plugins a try! Note that they are absolutely free, so this won’t cost you anything.