CN-114064411-B - Component detection method, device, equipment and storage medium
Abstract
The disclosure provides a component detection method, device, equipment and storage medium, relates to the technical field of computer software, and particularly relates to the technical field of software detection. The method comprises the steps of obtaining view structure data which is constructed in the running process of an application program and reflects page layout of a user interface, determining User Interface (UI) components associated with view elements in the view structure data, obtaining performance parameters of the UI components, wherein the performance parameters comprise type parameters and/or function parameters, and detecting high-performance consumption components in the UI components according to the obtained performance parameters, and performance consumption required by the high-performance consumption components is higher than a preset performance consumption threshold. By applying the scheme provided by the embodiment of the disclosure, the UI component with high performance consumption can be detected.
Inventors
- GAO FEI
- YANG BAOCHENG
Assignees
- 北京百度网讯科技有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20211122
Claims (13)
- 1. A component inspection method comprising: Obtaining view structure data which reflects the page layout of a user interface and is constructed in the running process of an application program; Determining all UI components associated with each view element in the view structure data; Matching a target identifier of a representation introduction mode in an attribute of a UI component with an identifier of a system introduction mode and an identifier of a developer introduction mode, if the target is matched with the identifier of the system introduction mode, determining the introduction mode of the UI component as the system introduction mode, and if the target identifier is matched with the identifier of the developer introduction mode, determining the introduction mode of the UI component as the developer introduction mode, wherein the introduction modes are divided into two types, namely the system introduction mode and the developer introduction mode, the system introduction mode means that an application program automatically introduces the UI component in a page rendering process, and the developer introduction mode means that codes written by a developer of the application program introduce the UI component; Screening UI components which are introduced by codes written by developers of the application program from all UI components according to the obtained introduction mode; Obtaining performance parameters of each UI component, wherein the performance parameters comprise type parameters and/or function parameters; Comparing the type parameters of each UI component with type values corresponding to preset types respectively under the condition that the performance parameters comprise the type parameters, and determining the UI component as a high-performance consumption component if the type parameters of the UI component are the same as the type values corresponding to the preset types, wherein the performance consumption required by the high-performance consumption component is higher than a preset performance consumption threshold; And the functional parameters are represented by character strings, and under the condition that the performance parameters comprise the functional parameters and the functional parameters are represented by character strings, the functional parameters of all the UI components are matched with the character strings corresponding to the preset functions, and if the matching is successful, the UI components are determined to be high-performance consumption components.
- 2. The method of claim 1, wherein the obtaining view structure data reflecting a page layout of a user interface constructed during an application program running process includes: View structure data reflecting the page layout of the user interface constructed when the application program is running in the debug mode is obtained.
- 3. The method according to any one of claims 1-2, wherein, The application program is a program developed based on Flutter technology; The view structure data are data corresponding to the Element tree; The UI component is a Widget component.
- 4. The method of any of claims 1-2, wherein, after the detecting a high-performance consuming component of the UI components according to the obtained performance parameters, further comprising: the severity of the impact of the detected component's performance consumption on the application's operation is obtained.
- 5. The method of any of claims 1-2, wherein, after the detecting a high-performance consuming component of the UI components according to the obtained performance parameters, further comprising: determining a cause of the detected high component performance consumption; according to the determined cause, a solution is obtained that reduces the performance consumption of the detected component.
- 6. A component inspection apparatus comprising: The data acquisition module is used for acquiring view structure data which is constructed in the running process of the application program and reflects the page layout of the user interface; The system comprises a component determining module, a component selecting module and a component selecting module, wherein the component determining module is used for determining all UI components associated with each view element in the view structure data, matching target identifiers of a representation introducing mode in attributes of the UI components with identifiers of a system introducing mode and identifiers of a developer introducing mode, determining the introducing mode of the UI components to be the system introducing mode if the targets are matched with the identifiers of the system introducing mode, and determining the introducing mode of the UI components to be the developer introducing mode if the targets are matched with the identifiers of the developer introducing mode, wherein the introducing mode is divided into two types, namely the system introducing mode and the developer introducing mode, the system introducing mode is that an application program automatically introduces the UI components in a page rendering process, the developer introducing mode is that codes written by the developer of the application program are introduced into the UI components, and screening the UI components introduced by codes written by the developer of the application program from all the UI components according to the obtained introducing mode; The performance parameter obtaining module is used for obtaining performance parameters of all the UI components, wherein the performance parameters comprise type parameters and/or functional parameters; The component detection module is specifically used for: Comparing the type parameters of each UI component with type values corresponding to preset types respectively under the condition that the performance parameters comprise the type parameters, and determining the UI component as a high-performance consumption component if the type parameters of the UI component are the same as the type values corresponding to the preset types, wherein the performance consumption required by the high-performance consumption component is higher than a preset performance consumption threshold; And the functional parameters are represented by character strings, and under the condition that the performance parameters comprise the functional parameters and the functional parameters are represented by character strings, the functional parameters of all the UI components are matched with the character strings corresponding to the preset functions, and if the matching is successful, the UI components are determined to be high-performance consumption components.
- 7. The apparatus of claim 6, wherein, The data obtaining module is specifically configured to obtain view structure data reflecting a page layout of the user interface, where the view structure data is constructed when the application program is running in a debug mode.
- 8. The device according to any one of claims 6-7, wherein, The application program is a program developed based on Flutter technology; The view structure data are data corresponding to the Element tree; The UI component is a Widget component.
- 9. The apparatus of any of claims 6-7, wherein the apparatus further comprises: And the severity obtaining module is used for obtaining the severity of the influence of the detected performance consumption of the components on the running of the application program after the component detecting module detects the high performance consumption components in the UI components.
- 10. The apparatus of any of claims 6-7, wherein the apparatus further comprises: and a solution obtaining module for determining a cause of high performance consumption of the detected component after the component detecting module detects the high performance consumption component in the UI component, and obtaining a solution for reducing the performance consumption of the detected component according to the determined cause.
- 11. An electronic device, comprising: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-5.
- 12. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-5.
- 13. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-5.
Description
Component detection method, device, equipment and storage medium Technical Field The present disclosure relates to the field of computer software technologies, and in particular, to the field of software detection technologies. Background In order to improve the smoothness of user operation of the user interface, the application program generally needs to set a proper refresh frequency for the user interface, so that the application program can be ensured to re-render the user interface at intervals corresponding to the refresh frequency. In the rendering process, an application program loads a component with an Interface layout function, hereinafter referred to as a UI (User Interface) component, and the UI component may cause performance consumption, and some UI components with higher performance consumption may make the time required in the rendering process longer, resulting in a lower refresh frequency, difficulty in reaching the set refresh frequency, and poor smoothness of User operation of the User Interface. In order to ensure the smoothness of the user operation user interface, it is necessary to detect UI components with higher performance consumption. Disclosure of Invention The present disclosure provides a component detection method, device, apparatus, and storage medium. According to an aspect of the present disclosure, there is provided a component detection method including: Obtaining view structure data which reflects the page layout of a user interface and is constructed in the running process of an application program; determining User Interface (UI) components associated with each view element in the view structure data; Obtaining performance parameters of each UI component, wherein the performance parameters comprise type parameters and/or function parameters; And detecting a high-performance consumption component in the UI component according to the obtained performance parameters, wherein the performance consumption required by the high-performance consumption component is higher than a preset performance consumption threshold. According to another aspect of the present disclosure, there is provided a component inspection apparatus including: The data acquisition module is used for acquiring view structure data which is constructed in the running process of the application program and reflects the page layout of the user interface; The component determining module is used for determining User Interface (UI) components associated with each view element in the view structure data; The performance parameter obtaining module is used for obtaining performance parameters of all the UI components, wherein the performance parameters comprise type parameters and/or functional parameters; And the component detection module is used for detecting a high-performance consumption component in the UI component according to the obtained performance parameters, wherein the performance consumption required by the high-performance consumption component is higher than a preset performance consumption threshold. According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the component detection method of any one of the preceding claims. According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform any one of the above-described component detection methods. According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the component detection method of any one of the above. Therefore, the view structure data reflect the page layout of the user interface actually required to be displayed in the running process of the application program, and the UI components associated with each view element in the view structure data are the UI components actually loaded in the process of displaying the user interface in the running process of the application program, so that the UI components with high performance consumption can be detected according to the performance parameters of the UI components, and the UI components actually loaded in the running process of the application program are detected. Therefore, when the scheme detection component provided by the embodiment of the disclosure is applied, the accuracy of component detection can be improved while the high-performance consumption component is detected. It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the di