|
- In this lesson you will learn the following concepts
- Overview
- Opening the project
- What is an audit?
- Static audit
- Procedure not run
- Orphan element
- Cleaning the project
- Dynamic audit
Lesson 10.1. Optimizing a project: audits In this lesson you will learn the following concepts - What is an audit and what is its purpose?
- Starting and analyzing the static audit.
- Starting and analyzing the dynamic audit.
Your site has been created. It works and will be deployed. Have you ever used WEBDEV tools to optimize your site? WEBDEV offers a series of tools and functionalities that allow you to quickly optimize your site and avoid major bugs. This part presents these tools and their use: - audits (in this lesson). Static and dynamic audits analyze your code to find potential issues.
- performance profiler (in the second lesson of this part).
We have prepared a project to help you better understand and use these tools! Opening the project - Open the "WW_Optimization" project.
- Start WEBDEV 28.
- Go to the WEBDEV home page if necessary (Ctrl + <).
- Click "Tutorial", and then in "Part 10 - Optimize a project", double-click "Optimize a project - Exercise".
Audits provide a set of features to automatically improve the project quality and performance, and to monitor the conditions in which it is implemented. Two types of audits are available: - The static audit. The static audit analyzes a project and its elements. This audit is performed from the project editor.
- The 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. 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:
- In the ribbon, go to the "Project" tab, "Audit and performance" group, expand "Static audit" and select "Start static audit".
- The wizard starts. We will define the target of the static audit.
- Select "Run the static audit on the entire project".
- Validate the wizard.
| | |  | Note | The static audit of the project can also be started from the project dashboard, via the "Static audit and Compilation" widget. Simply: - open the widget if necessary:
- Switch the dashboard to edit mode (right-click and select "Edit mode" in the context menu).
- Add the widget (right-click and select "Add .. Static audit").
- Exit the edit mode (right-click and select "Edit mode" again in the context menu).
- click the arrow.
|
- The audit report is displayed:
The static audit includes:
- The static audit of the project.
- The audit of the content of the application library.
- Let's take a closer look at the points presented in this report.
Procedure not run In our project, the audit indicates that a procedure is never run. 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:
- Click the [...] button to get more details. The window that lists the dead code opens.
- 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").
- In our case, this procedure is not used, click "Delete".
- A window prompts you to confirm the deletion. Click "Delete" to confirm the deletion.
- 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.
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 unnecessarily consumes the resources distributed to the end users. - To fix this problem:
- Click the [...] button to get more details. The window that lists the orphan elements opens.
- 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").
- In our case, "PAGE_Unused_Page" is not used, click "Delete".
- 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.
Cleaning the project Our project contains multiple files that are not used. You can clean the project to keep the necessary elements only. The client setup is not cluttered with unused files: images, external files, etc. - To fix this problem:
- Click the [...] button to get more details.
- The project cleanup wizard starts. This wizard shows the unused files that can be deleted.
- Go to the next step.
- Select the type of cleanup. You can:
- create a zip file with the unused files.
- move the unused files to a specific directory.
- Validate the option proposed by default and go to the next step.
- 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. 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,
- ...
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:
- 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.
| | |  | Note | The dynamic audit of the project can also be started from the project dashboard, via the "Dynamic audit" widget. To do so:- enable the widget if necessary (click the link "Click here to re-enable").
- expand the arrow and select "In-depth project test (Go)".
Remark: The dynamic audit is executed each time the project is tested. A status report is automatically displayed in the dashboard: |
- Click "TEST PAGE OF DYNAMIC AUDIT".
- 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.
- Stop the site test.
- The dynamic audit report window appears.
- 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, 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:
- 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 button allows you to open the code editor directly at the corresponding location in order to fix the problem.
- Close the dynamic audit window.
| | |  | Note | The dynamic audit of a project can also be performed when the site is deployed.All you have to do is call dbgEnableAudit to trigger the dynamic audit.
The audit generates a ".wdaudit" file, this file must be loaded in the development environment to analyze the result. |
|
|
|
|
|
|
|