Profiling unit tests

Code profiling for .NET Developers

Profiling unit tests

Postby ShaneMRyan » Thu Dec 13, 2012 10:38 am

We already have a license for ANTS and for our day-to-day profiling we’re pretty happy with it.

However what we are interested in is profiling of unit tests on an integration server. So for instance we use TeamCity/Nunit and we’d like to be able to run unit tests to highlight a block of code and have the unit test fail if the number of cpu cycles for the block of code increases by more than x percent.

So for example:

Void PerformanceUnitTest1()
//setup code


For(int i=0; I < 10000000; i++
Console.write(“hello world”);

long numberOfCPUCycles = SpeedTrace.GetCyles();

Assert.(500000*1.2 > numberOfCPUCycles); // took more than the 500,000 cpu cycles plus 20%

If we could do something like this to help automate our profiling it would be very useful to us.
Posts: 1
Joined: Thu Dec 13, 2012 10:37 am

Postby dene.boulton » Thu Dec 13, 2012 2:12 pm


The way you would have to currently approach this would be to have a build step where you run a process for the command line profiler (available in APP Pro) that profiles the nunit command line runner and provide the arguments to the nunit runner for the assembly to process.
Provide the Profilers with command line arguments to profile child processes and output the results to an xml file.

Then assert on the content of the xml file for the particular methods running values.

Edit: also see this support item - ... 0708000125
Dene Boulton
Red Gate
Posts: 42
Joined: Wed Oct 12, 2011 11:44 am
Location: Cambridge

Return to ANTS Performance Profiler Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests