To illustrate how to use the Performance profiler for timing the execution of routines and source code lines, we will use a sample application, Cycles, installed with AQTime.
Managed code
Microsoft Visual Studio 2005 projects:
<AQTime Samples>\Managed\VS2005\Performance\CS - Microsoft Visual C# .NET
<AQTime Samples>\Managed\VS2005\Performance\JS - Microsoft Visual J# .NET
<AQTime Samples>\Managed\VS2005\Performance\VB - Microsoft Visual Basic .NET
<AQTime Samples>\Managed\VS2005\Performance\VC - Microsoft Visual C++ .NET
Microsoft Visual Studio 2013 projects:
<AQTime Samples>\Managed\VS2013\Performance\CS - Microsoft Visual C# .NET
<AQTime Samples>\Managed\VS2013\Performance\VB - Microsoft Visual Basic .NET
<AQTime Samples>\Managed\VS2013\Performance\VC - Microsoft Visual C++ .NET
Unmanaged code
<AQTime Samples>\Unmanaged\Performance\VC2005 - Microsoft Visual C++ (Visual Studio 2005 project)
<AQTime Samples>\Unmanaged\Performance\VC2013 - Microsoft Visual C++ (Visual Studio 2013 project)
<AQTime Samples>\Unmanaged\Performance\VB - Microsoft Visual Basic 6.0
<AQTime Samples>\Unmanaged\Performance\Delphi - Borland Delphi
<AQTime Samples>\Unmanaged\Performance\BCB - Borland C++Builder
Note: | You can also open Visual Studio samples in later versions of Visual Studio. |
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. |
To profile this example with AQTime, do the following:
-
Open the application in AQTime.
-
Select Performance Profiler from the Profilers drop-down list on the Standard toolbar.
Select Performance Profiler from the Profilers drop-down list displayed in the AQTime menu of Microsoft Visual Studio.
Select Performance Profiler from the Current Profiler submenu displayed in the AQTime menu of Embarcadero RAD Studio.
-
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.
-
Disable All Project Modules, Entire Script Code and Entire .NET Code in the Setup panel. (Review About Areas for the details of defining areas and selecting the code to profile.)
-
Create a new including routine-level area. See Creating, Editing and Deleting Areas and Profiling Levels for details.
-
In our sample, we will profile only those routines whose performance we can affect, i.e. the routines whose source code we can change (this is the code that resides in the compiler-specific subfolder of the <AQTime Samples> folder). For this purpose, select Source File from the View By drop-down list box in the Setup panel, expand the Cycles.exe node, select all the files that belong to the sample’s source folder, add them to the area we have created and check this area. For instance, for the Visual C++ sample, there will be four .cpp files we need to add.
The approach described above can be used when you want to locate and fix performance bottlenecks that are caused by your own code. However, this approach is not suitable if your routines call functions from third-party libraries and the bottlenecks in your routines are actually caused by these functions. To locate such functions, you may need to enable All Project Modules and even Entire .NET Code (for managed code). See About Areas. -
Create a new including line-level area, add the
ProfilingTest
routine to it and check this area. -
Verify that the Enable/Disable Profiling button on the Standard toolbarin the AQTime menu of Visual Studioin the AQTime menu of RAD Studio is pressed since AQTime only profiles when this button is pressed.
-
Select Options > Options from AQTime’s main menu Select Tools > Options > AQTime from Visual Studio’s main menu Select AQTime > Options from Embarcadero RAD Studio’s main menu to display the Options dialog.
In the dialog, select Profilers > Performance > Performance Profiler from the list on the left. Make sure the Active counter option is set to Elapsed Time.
-
Press Run on the Standard toolbar.
Select Run from Visual Studio’s AQTime menu, or press Visual Studio’s Run button while any of AQTime panels is active.
Select Run With Profiling from Embarcadero RAD Studio’s AQTime menu.
-
Depending on the Show Again Flags options, AQTime may call the Profiler Options dialog. Make sure the Active counter option is set to Elapsed Time there and press Run to start profiling.
-
AQTime will launch the profiled application. Wait until the application window is displayed on the screen.
-
In Cycles, enter 10 and then press Execute. Wait while Cycles performs a series of actions.
-
Close Cycles and review profiler results.