To illustrate how you can use the Performance profiler to find performance bottlenecks, we will use a sample application that is supplied with AQTime, JuliaSet. This application performs a few mathematical calculations and builds a fractal. You can find this sample application in the following folders:
|On Windows Vista and later, AQTime samples are located in the <Users>\Public\Documents\AQTime 8 Samples folder. On other operating systems, the samples reside in the <Documents and Settings>\All Users\Documents\AQTime 8 Samples folder.|
|Note:||In this tutorial, we will use the managed version of the sample application.|
To find bottlenecks in the application, we are going to profile it in two steps. At first, we are going to profile the entire application and find a bottleneck, that is, the slowest routines. Then we are going to profile those particular routines line by line and find the cause of the bottleneck.
Let's start with configuring a profiling project and profiling the entire application.
Open the sample application in AQTime.
Select Performance Profiler from the Profilers box on the Standard toolbar.
Select Performance Profiler from the AQTime > Profilers item in the main menu of Visual Studio.
Select Performance Profiler from the Current Profiler submenu of Embarcadero RAD Studio’s AQTime menu.
Select Normal from the Profiling Mode drop-down list box that is displayed on AQTime’s Standard toolbar.
Select Normal from the Profiling Mode drop-down list box that is displayed on Visual Studio’s AQTime toolbar.
Click the Normal button on RAD Studio’s AQTime Profiling Modes toolbar.
Verify that the Enable/Disable Profiling button on the Standard toolbar in the AQTime menu of Visual Studio in the AQTime menu of RAD Studio is pressed since AQTime performs profiling only when this button is pressed.
Make sure that the All Project Modules (Routines only) profiling area is selected. Using the Routines only option makes profiling faster.
Select Options > Options from AQTime’s main menu to display the Options dialog.
Select Tools > Options from the main menu of Visual Studio to display the Options dialog.
Select AQTime > Options from the main menu of Embarcadero RAD Studio to display the Options dialog.
In the dialog, select the General > Show Again FlagsAQTime > General > Show Again FlagsGeneral > Show Again Flags from the list on the left. Enable the Performance Profiler option in the Show profiler options when profiling starts section and press OK to save the changes and close the dialog.
Press Run to start profiling.
Select AQTime > Run to start profiling. An alternative way to start profiling is to press Visual Studio’s Run button while any AQTime panel is active.
Select AQTime > Run With Profiling to start profiling.
Since the Performance Profiler option on the Show Again Flags option page is enabled, AQTime will call the Profiler Options dialog where you can set profiler options before the profiling starts. We will modify the value of the Active Counter option. This option allows you to specify what characteristics the profiler will measure. In the given run, let's use the Elapsed Time counter.
Press Run to start profiling.
AQTime will launch the profiled application. Wait until the application window is displayed on the screen.
In the application, click the Draw button to start the calculation. Wait until the fractal has been drawn.
Close the application.
As you can see, the calculation lasted for a long time, so it’s obvious that the application needs to be optimized. In the next step we will analyze the profiling results and find the bottleneck.