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.
It’s not exactly what you are looking for but in the ‘All Methods’ grid in ANTS Performance Profiler, when you have the results set that you are interested in you could use the: Ctrl + A, then Ctrl + C to copy the contents of the methods grid which would contain all the methods with their times and hit count.
If sorted by the column you are most interested in then you are more than half way through.
You could simply paste the data into Excel very easily for example and do what you want with it from there.
Automation of exporting results would be a nice addition and something that may be implemented in future versions.
Kind regards,
Stephen
@Stephen-
I ended up with just that (pulling into Excel). Automation via TeamCity/Hudson or such would be rockin’.
Hi David,
we wouldn’t want to pass up an opportunity to get people rockin’, that’s for sure.
Be in touch,
Stephen