ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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

Tutorial - Optimizing a WEBDEV 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
WEBDEV provides you with several website optimization tools. You can improve performance and avoid bugs before deploying your website.
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 are going to test these audits on the "WW_Optimization" project.

Opening the project

This tutorial uses the "WW_Optimization" project. To open this example:
  1. Go to the WEBDEV home page (Ctrl + <).
  2. On the home page, click "Tutorial", then in "Tutorial - Optimize a WEBDEV project", double-click "Optimize a project - Exercise".
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 "WW_Optimization" project:
  1. In the ribbon, go to the "Project" tab, "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 wizard
  3. Select "Run the static audit on the entire project".
  4. Finish the wizard.
  5. The audit report is displayed:
    Static audit report
The static audit includes:
  • the audit report (which we will look at in detail below).
  • the analysis of the application library.
For more details, see Static audit.
Let's take a closer look at the points presented in this report.

Optimization 1: Procedure not executed

In our project, the audit indicates that a procedure is never executed.
In large projects, you may want to create one or more procedures to perform a process then, further to a code reorganization, the procedure is no longer used but it 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.
    Dead code in the project
  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 2: Orphan element

The audit indicates that our project contains an orphan element.
Just like with procedures, windows or reports can be created to run a quick test, then be saved and forgotten. 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 opens.
    Orphan elements in the project
  2. The "PAGE_Unused_Page" page 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 page will no longer be taken into account in the audit. This option can be useful when using a test page specific to a development project, for example.
    • delete the page if it is not used ("Delete").
    • see the page ("View").
    • find the occurrences in the strings ("Search").
  3. In our case, "PAGE_Unused_Page" is not used, 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 3: Cleaning the project

Our project contains multiple unused files. You can clean the project to keep only the necessary elements. The client setup is not cluttered with unused files: images, external files, etc.
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. Our advice: 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 "WW_Optimization" project contains a specific page 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 "WW_Optimization" project:
  1. In the ribbon, 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 "TEST PAGE OF DYNAMIC AUDIT".
  3. Click the different buttons in the page.
    • At the end of each process, a toast message is displayed to specify that the process is over.
      Remark: Wait for the toast to be displayed before clicking another button.
    • For the "Assertion and Exception" option, an assertion is displayed: click "Continue" to see the message appear as a toast.
  4. Stop the website test.
  5. The dynamic audit report window appears.
    Report of the dynamic audit
Let's analyze this window:
  • 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. When data is displayed in chronological order, a timeline shows the position and importance of the issues.
    • choose the type of issue to be displayed (error, assertion, etc.). This allows you to focus on major errors.
  • 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:
  • A SWITCH statement for which no CASE is run,
  • A triggered assertion,
  • A triggered exception,
  • 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 Open code editor 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 the website is deployed. You can use dbgEnableAudit to start the dynamic audit.
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/08/2023

Send a report | Local help