An API would be REALLY useful/Can I profile parts of tests?

I have a unit tests which simulates a slow usage scenario and I want to profile a certain part of this unit test method with the ANTS Performance profile. How can I do this?

Something similar to the old profiler API (the RedGate.Profiler.Api.dll) would be very useful for this!

Does such an API exist or is it planned? Is there any alternative?

Thank you very much,


  • There is an API available for ANTS which can mark regions on the timeline: see 'adding custom event markers' here for details. Once the regions are marked, you can just select those relating to the tests you're interested in.

    However, this is probably unncecessary for unit tests: as these are implemented as individual methods, you can just select the relevant method in the list. ANTS will draw a green bar on the timeline to show the times when the method was running, and you can click on this to inspect what was going on during that time. The call graph is also very useful for inspecting how an individual method is behaving.
    Andrew Hunter
    Software Developer
    Red Gate Software Ltd.
  • If you're looking for pointers on how to set up profiling for your unit test, and it's in Nunit or MSTest, then you may find the following instructions useful:
    * Profiling units tests using NUnit
    * Profiling tests in MSTest
    Essentially, both methods involve telling ANTS Performance Profiler to profile your test assembly. When it's profiling you can then, as Andrew suggests, use the call tree to select the method for the test in which you're interested.
Sign In or Register to comment.