ANTS Performance Profiler

Latest version: 7.4

ANTS Performance Profiler

Knowledge Base

Finding the overall time taken to execute a thread

Category: How do I?
Date: 17 Jun 2009
Product: ANTS Performance Profiler
Versions: 3,4

ANTS Profiler can display performance profiling results by thread when profiling a multithreaded application. This is how to work out the overall time taken to execute a particular thread.

ANTS Profiler can be used to find the total time taken to run a particular thread.

In version 4, this is simply a matter of pulling down the thread list "(All Threads)" and selecting the thread by name. The highest method at the top of the stack trace will show the total execution time in the time with children statistic. If the thread has not been assigned a name in your code, you must work out which method is the entry point for the thread, normally present in the ThreadStart constructor.

Thread t = new Thread(new ThreadStart(webproxy.Run));
t.Start();

You can choose each thread from the "(All Threads)" dropdown until you see the "webproxy.Run" method near the top of the call stack. If you have source code available, it would probably be the first method in the top-down call graph which is in bold text.

In version 3 the procedure is slightly different in that the thread list appears in the "Results" pane of the user interface. Each set of performance profiling results can be expanded to show individual threads of a multithreaded application. Clicking on one of these threads will filter the profiling results in the "all methods" panel to only the methods in that thread, and show only the time taken in that thread. In the above example, clicking the thread containing the WebProxy.Run method and examining the time with children for "webproxy.Run" will give you the total thread time.

In order to simplify finding the correct thread in any case, we recommend naming your threads in your code. For example, the code fragment below creates a thread and names it "Proxy Thread". This thread will be much easier to locate because ANTS Profiler 3 and 4 will display this thread by name in the results.

     Thread t = new Thread(new ThreadStart(webproxy.Run));
     t.Name="Proxy Thread";

If multiple instances of this thread have been started, they will still be differentiated by the thread ID as well as the thread name.

* NB ANTS Profiler 3.2.0.27 is the only version lower than version 4 which will display thread names.

Document ID: KB200801000218 Keywords: ANTS, Profiler,Thread,results,ThreadStart,performance

Was this article helpful?

Search support
Forums

ANTS Performance Profiler

all products