Profiling unit tests

Code profiling for .NET developers.

Moderators: AndrewH, melvyn.harbour, james.billings, Laura Morley, dene.boulton

Profiling unit tests

Postby ShaneMRyan » Thu Dec 13, 2012 11: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:

[Test]
Void PerformanceUnitTest1()
{
//setup code

SpeedTrace.startprofiling();

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

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.
ShaneMRyan
 
Posts: 1
Joined: Thu Dec 13, 2012 11:37 am

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

Hello,

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 - http://www.red-gate.com/SupportCenter/c ... 0708000125
Dene Boulton
Red Gate
dene.boulton
 
Posts: 53
Joined: Wed Oct 12, 2011 12:44 pm
Location: Cambridge


Return to ANTS Performance Profiler 7

Who is online

Users browsing this forum: No registered users and 0 guests