ANTS Performance Profiler 11

Help for older versions available.

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

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 Performance 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:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Threading;
  5.  
  6. namespace TestThreadTimes
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Thread t1=new Thread(new ThreadStart(WaitThreeSeconds));
  13. t1.Name = "FirstThread";
  14. t1.Start();
  15. t1.Join();
  16. Thread t2 = new Thread(new ThreadStart(WaitThreeSeconds));
  17. t2.Name = "SecondThread";
  18. t2.Start();
  19. t2.Join();
  20. }
  21. static void WaitThreeSeconds()
  22. {
  23. Thread.Sleep(3000);
  24. }
  25. }
  26. }

Didn't find what you were looking for?