Using RedGate ANTS to Profile XUnit Tests
RedGate’s ANTS Performance and Memory profilers can do some pretty slick testing, so why not automate it? The “theory” is that if my coverage is hitting all the high points, I’m profiling all the high points and can see bottlenecks.
So, how does this work? Since the tests are in a compiled library, I can’t just “load” the unit tests. However, you can load Xunit and run the tests.
NOTE: If your profiling x86 libraries on an x64 machine, you’ll need XUnit 1.5 CTP (or later) that includes xunit.console.x86.exe. If you’re on an x86 or do not call x86 libraries, pay no attention to this notice.😉
To begin, start up ANTS Performance Profiler and Profile a New .NET Executable.
For the .NET Executable, point it towards XUnit and in the Arguments, point it towards the library you are testing. Simple enough.
Click “Start Profiling” and let the profiling begin!
Now if I could just get the “top 10” methods to export to HTML or something so I could automate this in our reporting.