ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

New WINDEV 2024 feature!
Help / WINDEV Tutorial / Tutorial - Optimizing a project
  • Lesson 1 - Project audits
  • Overview
  • What is an audit?
  • Static audit
  • Optimization 1: Table control (UI)
  • Optimization 2: Procedure not executed
  • Optimization 3: Orphan element
  • Optimization 4: Cleaning the project
  • Dynamic audit
  • Conclusion

Tutorial - Optimizing a project

Lesson 1 - Project audits
We will cover the following topics:
  • What is an audit and what is its purpose?
  • Starting and analyzing the static audit.
  • Starting and analyzing the dynamic audit.
Durée de la leçon 15 mn
Overview
WINDEV includes several tools to help you optimize your applications. You can improve performance and avoid bugs before deploying the applications.
This tutorial explains how to use some of these tools.
In this lesson, we will cover the different audits available, and in the next lesson, we will see how to use the performance profiler.
We have prepared a project to help you better understand and use these tools!
What is an audit?
Audits provide a set of features used to:
  • automatically improve the quality and performance of a project.
  • monitor how it is put into production.
Two types of audits are available:
  • Static audit. The static audit analyzes a project and its elements. This audit is performed from the project editor.
  • Dynamic audit. The dynamic audit analyzes the behavior of a project during its execution. This audit can be performed in test mode or in the production environment.
We will run these audits on the "WD Optimization" project.
Opening the project
This tutorial uses the "WD Optimization" project. To open this example:
  1. Go to the WINDEV home page (Ctrl + <).
  2. On the home page, click "Tutorial", then in "Tutorial - Optimize a project", double-click "Optimize a project".
Warning
This project will be used in the different lessons of this tutorial.
Static audit
The static audit is a feature of the environment used to analyze the source code of a project in order to detect various problems and to propose improvements.
To start the static audit on the "WD Optimization" project:
  1. On the "Project" tab, in the "Audit and performance" group, expand "Static audit" and select "Start static audit".
  2. The wizard starts. We will define the target of the static audit.
    Static audit
  3. Select "Run the static audit on the entire project".
  4. Finish the wizard.
  5. The audit report is displayed:
    Audit report
The static audit includes:
  • the audit report (which we will look at in detail below).
  • the analysis of the application library.
  • the analysis of the application installation package.
For more details, see Static audit.
Let's take a closer look at the points presented in this report.

Optimization 1: Table control (UI)

In our project, the audit indicates that a Table control uses the standard search mode. This mode ('Starts with') searches for elements that start with the given characters. The audit suggests using the 'Contains' filter by default, which is much more common and useful for users.
To fix this problem:
  1. Click the [...] button to get more details. A window with UI improvement suggestions appears.
    UI improvements
  2. In "WIN_UnusedWindow", the "TABLE_Product" control can be improved. This window is used to:
    • make the improvement ("Improve"). In this case, the improvement is made immediately.
    • ignore the improvement ("Ignore"). In this case, the improvement suggestion will no longer appear.
  3. In our example, we will make this change. Click "Improve".
  4. To apply all the selected improvements (only 1 in our example), click "Confirm actions".
In the static audit window, click the "Refresh" button to update the audit report.

Optimization 2: Procedure not executed

In our project, the audit indicates that a procedure is never executed. This happens very often: developers may create a process and reorganize code. The procedure is then no longer used but remains in the project.
These unused procedures unnecessarily overload the resources distributed to end-users.
To fix this problem:
  1. Click the [...] button to get more details. The window that lists the dead code opens.
    Procedure not executed - Dead code
  2. The "ObsoleteProcedure" procedure is never called. This window is used to:
    • specify that the procedure is still used ("Mark as useful"). In this case, the procedure will no longer be taken into account in the audit.
    • delete the procedure if it is not used ("Delete").
    • see the procedure ("View").
    • find the occurrences in the strings ("Search").
  3. In our case, this procedure is not used, click "Delete".
  4. A window prompts you to confirm the deletion. Click "Delete" to confirm the deletion.
  5. Close the dead code window (click "X" in the upper-right corner).
In the static audit window, click the "Refresh" button to update the audit report.

Optimization 3: Orphan element

The audit indicates that our project contains an orphan element. This also happens very often: developers may create and save windows and reports for a quick test, and then forget to remove them from the project.
The presence of orphan elements in the executable file unnecessarily overloads the resources distributed to end users.
To fix this problem:
  1. Click the [...] button to get more details. The window that lists the orphan elements is displayed.
    Orphan element
  2. The "WIN_UnusedWindow" window is never called. The window that lists the orphan elements is used to:
    • specify that the element is still used ("Mark as useful"). In this case, the window will no longer be taken into account in the audit. This option can be useful when using a test window specific to the development for example.
    • delete the element if it is actually unused ("Delete").
    • see the element ("View").
    • find the occurrences in the strings ("Search").
  3. In our case, this "WIN_UnusedWindow" window is actually unused, click "Delete".
  4. Close the window of orphan elements (click the "X" in the upper-right corner).
In the static audit window, click the "Refresh" button to update the audit report.

Optimization 4: Cleaning the project

Our project contains multiple unused files. You can clean the project to keep only the necessary elements. This avoids overloading the executable file and the setup program with unused images, external files (or other).
To fix this problem:
  1. Click the [...] button to get more details.
  2. The project cleanup wizard starts. This wizard shows the unused files that can be deleted.
  3. Go to the next step.
  4. Select the type of cleanup. You can:
    • create a zip file with the unused files.
    • move the unused files to a specific directory.
  5. Keep the default option and go to the next step.
  6. Finish the wizard.
Our project has been optimized by following all the tips of the static audit.
The static audit is used to get an overall status on the source code of your project. Run it on a regular basis!
Let's see what happens at runtime when the dynamic audit is started.
Dynamic audit
The dynamic audit is used to analyze the application execution. The audit detects problems such as:
  • Excessive memory consumption,
  • Slowness of algorithms used,
  • Errors "hidden" at runtime,
  • etc.
A dynamic audit can be performed in a test environment or on a live application.
The "WD Optimization" project contains a specific window triggering errors that can be detected by the dynamic audit.
The dynamic audit and the project test will be started at the same time.
To start the dynamic audit on the "WD Optimization" project:
  1. On the "Project" tab, in the "Test mode" group, expand "Test mode" and select "Debug project while the audit is enabled". The project test is run.
  2. Click the "Test window of dynamic audit" button.
  3. Click the different buttons in the window. At the end of each process, a toast message is displayed to specify that the process is over. For the "Assertion and Exception" option, an assertion is displayed: click "Continue" to see the message appear as a toast.
  4. Stop the application test.
  5. The report window of the dynamic audit appears.
Let's analyze this window:
Report of the dynamic audit
  • The top section of this window allows you to choose the data display options. You can:
    • choose a chronological display (based on the order in which the events occurred) or an overall display, used to group the different types of issues. In this case, the timeline allows you to see the position and importance of the problems.
    • choose the type of issue to be displayed (error, assertion, etc.). This allows you to focus on major errors, etc.
  • The bottom section of this window displays the different events that occurred and that may cause problems in the application.
In this example, the dynamic audit detects several problems:
  • An overly long text assigned programmatically,
  • A SWITCH loop for which no CASE is run,
  • An assertion is triggered instead of an exception,
  • Opening a file that does not exist,
  • The assignment of a nonexistent image file to an Image control. For each problem, a "..." button allows you to access the details of the event. If the event is linked to a specific line of code, the button allows you to open the code editor directly at the corresponding location in order to fix the problem.
Warning
This lesson only shows an overview of the dynamic audit, we will not fix all the errors.
Close the dynamic audit window.
Conclusion
Static and dynamic audits are two essential tools that help you quickly identify problems or bottlenecks in your application.
You can also find these tools in the project dashboard.
In the next lesson, we will use another tool: the performance profiler.
Further information: The dynamic audit of a project can also be performed when an application is deployed on the user computers. You can:
  • modify the application and use dbgEnableAudit to start the audit.
  • use a text file in the application directory. This solution allows you not to modify the executable.
For more details, see Dynamic audit.
Table of contentsNext Lesson
Minimum version required
  • Version 2024
Comments
Click [Add] to post a comment

Last update: 12/04/2023

Send a report | Local help