Profiling means collecting program parameters during its execution. During a profiling, the execution time and the number of calls of individual functions and program code lines are measured. With this tool, the programmer is able to find and optimize the slowest code sections.
Profiling can be performed on the normal chart of the trading platform, as well as using history data in the Strategy Tester. In the first case, a program is launched on a chart that is updated in real time. You can check the program behavior in real conditions. In the second case, the program is launched in the Strategy Tester in the visual mode. The advantage of this method is that you do not need to wait for real data from a trade server or occurrence of certain trading conditions.
Many programs, especially indicators, only perform calculations at the arrival of a new tick (OnTick, OnCalculate). Thus, in order to evaluate performance, you have to wait for new ticks in real time. When profiling using history data, you can immediately provide the required load and test the program performance even on weekends when markets are closed.
After that, a special program version for profiling will be compiled automatically. Depending on the selected profiling type, the program will be launched on a normal chart in the trading platform or in the Strategy Tester (in the visual mode).
By default, an application is launched on EURUSD H1. To launch it on another symbol or period, specify them on the Debug tab in the MetaEditor settings.
After the launch, work with the application for some time to try all its features to the maximum. This is necessary in order for the profiler to measure the execution time of all program's functions and lines.
For more accurate profiling results, it is recommended to manually remove the program from the chart instead of using the Stop Profiling command.
After profiling is finished, its results are displayed in the Profiler tab of the Toolbox window. Results can be viewed in two modes: by calls and by lines. Use the context menu to switch between them.
In this mode, the profiling results are presented by functions:
The icons allow you to specify type of functions:
In addition to these types of functions, the profiler displays:
To view a function in a file, double-click on it.
The profiler displays not all functions but only the ones called during the program operation.
In this mode, the data on the program operation time is represented by lines. Lines are grouped by program functions.
To view a line in a file, double-click on it.
The following commands are available in the context menu: