ANTS Profiler

Latest version: 4.3

ANTS Profiler

Knowledge Base

Showing the amount of time taken for a method in one particular thread

Category: How do I?
Date: 17 Jun 2009
Product: ANTS Profiler
ANTS Performance Profiler's results screen has a dropdown list labeled "Thread". This allows you to choose results relative to a particular thread.

For instance, in the example code below, the same method is called from two different threads: one is called "FirstThread" and the other is called "SecondThread". Viewing the profiling results with "all threads" selected will show a hit count of "2" and a total time of "6 seconds", assuming ANTS Profiler is set up to display wall-clock time.

Selecting "FirstThread" or "SecondThread" from the dropdown will show a hit count of "1" for the same method, and a total runtime of "3 seconds". The source code view will reflect the same behavior. The following is the code of the example C# application created to demonstrate this result:

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace TestThreadTimes
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread t1=new Thread(new ThreadStart(WaitThreeSeconds));
            t1.Name = "FirstThread";
            t1.Start();
            t1.Join();
            Thread t2 = new Thread(new ThreadStart(WaitThreeSeconds));
            t2.Name = "SecondThread";
            t2.Start();
            t2.Join();
        }
        static void WaitThreeSeconds()
        {
            Thread.Sleep(3000);
        }
    }
}

Document ID: KB200811000329 Keywords: ANTS, Profiler,thread,total,time

Was this article helpful?

Search support
Forums
Visit the ANTS Profiler forum.

ANTS Profiler

all products