The sections below describe how you can find the minimum, maximum or average execution time of methods in your applications:
Using the Performance Profiler
The Performance profiler traces an application's various performance characteristics. To find the minimum, maximum or average execution time of methods in your application, do the following:
Profile your application with the Performance profiler using the Elapsed Time, User Time or User+Kernel Time counter.
Check the Average Time, Max Time and Min Time columns. These are all for the method’s own code, exclusive
the time spent on calling other methods.
The Average Time with Children, Max Time with Children and Min Time with Children columns count not only the time taken up by the method’s own code, but also the entire call, including child calls.
Note: If a required column is hidden in the panel, right-click within the panel, choose Field Chooser from the context menu and drag the needed column from the subsequent Field Chooser dialog to the panel.
The time spent on the first call to a routine may differ from the time spent on subsequent calls to it due to initializations which are normally performed during the first call. To know the time of the first call to each profiled routine, check the First Time and First Time with Children columns.
Using the Function Trace Profiler
The Function Trace profiler traces the sequence of function calls and logs the execution time and parameters of method calls. To find the minimum, maximum or average execution time of methods in your application, do the following:
- Run the Function Trace profiler using the Elapsed Time, User Time or User+Kernel Time counter.
- Generate results and select the Call Trace result category in the Explorer panel. The Report panel will display the sequence of function calls for the thread selected in the Explorer panel. Each row in the Report panel will correspond to a function call.
- Switch to the Report panel and filter results by the Routine Name column so that the panel displays rows corresponding to calls of the desired routine. See Filtering Results for more information.
- Sort rows by the Time or Time With Children column to find the maximum and minimum execution time for the routine (see Sorting Results).
Despite the fact that the search for the minimum and maximum execution time in Function Trace results requires more operations, it still gives you one benefit: if you double-click a row in the Report panel, the Details panel will show parameter values used for the function call. In other words, by analyzing the Function Trace profiler results you can find parameters passed to and received from the routine when its execution takes the maximum or minimum amount of time.