A speed measurement method and device for APP page loading and a storage medium
By obtaining the start and end times of page loading, traversing the page view tree, and recording image decoding callbacks, the problem of high performance consumption in existing technologies is solved, and efficient page load time measurement is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-01
- Publication Date
- 2026-03-24
AI Technical Summary
Existing methods for testing app page speed require continuous polling of page integrity, resulting in high system performance consumption and negatively impacting user experience.
By obtaining the start and end times of page load, we traverse the page view tree to get all images on the screen, add decoding callbacks, record the decoding completion time, and calculate the page load time.
Accurately capturing the page load time as perceived by the user reduces performance consumption and improves the user experience.
Smart Images

Figure CN114238051B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of client performance monitoring, in particular to a method and device for measuring the loading speed of an APP page and a storage medium. BACKGROUND
[0002] It is found through research that the opening speed of an APP page has an important influence on user experience. The opening speed of a page and the display content in the page have a strong correlation. In order to optimize user experience and improve the opening speed of a page, a plug-in is often used to detect the opening speed of the page.
[0003] The speed measurement method in the prior art needs to constantly poll whether a display page is complete, which consumes a large amount of system performance and affects user experience.
[0004] Therefore, it is necessary to improve the detection method for the opening speed of an APP display page to reduce the performance consumption of speed measurement. SUMMARY
[0005] The application aims to provide a method and device for measuring the loading speed of an APP page and a storage medium to reduce the performance consumption of speed measurement.
[0006] In order to achieve the above-mentioned purpose, the application provides a method for measuring the loading speed of an APP page, which comprises the following steps:
[0007] obtaining a page loading start time, traversing a page view tree when a page loading key frame is loaded, and obtaining all pictures required to be displayed in a screen; the key frame is a rendering completion frame loaded after an interface request of the page is completed;
[0008] adding a decoding callback to all pictures required to be displayed in the screen and recording an end time of decoding callback completion of all pictures required to be displayed; the end time is a page loading end time;
[0009] obtaining a page loading time according to the page loading end time and the page loading start time.
[0010] Further, when the page loading key frame is loaded, the page view tree is traversed, and the traversing specifically comprises the following steps:
[0011] after an interface request of a page for which the loading time needs to be counted is completed, inserting a component code, the component code being used to obtain view information and determine the page loading key frame;
[0012] when the page loading key frame is loaded, the page view tree is traversed.
[0013] Further, the decoding callback is added to all pictures required to be displayed in the screen, and the end time of decoding callback completion of all pictures required to be displayed is recorded, and the adding and recording specifically comprise the following steps:
[0014] decode callback of each picture is completed, set the picture as having completed the decode callback;
[0015] When all pictures are set as having completed the decode callback, record the end time of the decode callback completion of all pictures required to be displayed.
[0016] Further, the page loading time is obtained according to the page loading end time and the page loading start time, specifically:
[0017] Subtract the page loading start time from the page loading end time to obtain the page loading time.
[0018] The application further discloses a speed measuring device for APP page loading, which comprises a first acquisition module, a second acquisition module and a result output module.
[0019] The first acquisition module is used for acquiring the page loading start time, and when a page loading key frame is loaded, the page view tree is traversed to acquire all pictures required to be displayed in a screen.
[0020] The second acquisition module is used for adding a decode callback to all pictures required to be displayed in the screen and recording the end time of the decode callback completion of all pictures required to be displayed.
[0021] The result output module is used for obtaining the page loading time according to the page loading end time and the page loading start time.
[0022] Further, when the page loading key frame is loaded, the page view tree is traversed, specifically:
[0023] After the interface request of the page required to be used for counting the page loading time is completed, a component code is inserted, and the component code is used for acquiring view information and determining the page loading key frame.
[0024] When the page loading key frame is loaded, the page view tree is traversed.
[0025] Further, the decode callback is added to all pictures required to be displayed in the screen, and the end time of the decode callback completion of all pictures required to be displayed is recorded, specifically:
[0026] Decode callbacks are added to all pictures required to be displayed in the screen one by one, and after the decode callback of each picture is completed, the picture is set as having completed the decode callback.
[0027] When all pictures are set as having completed the decode callback, the end time of the decode callback completion of all pictures required to be displayed is recorded.
[0028] Further, the page loading time is obtained according to the page loading end time and the page loading start time, specifically:
[0029] The page loading time is obtained by subtracting the page loading start time from the page loading end time.
[0030] The application further discloses a computer readable storage medium, which comprises a stored computer program, wherein the computer readable storage medium controls a device where the computer readable storage medium is located to execute the APP page loading speed measurement method when the computer program runs.
[0031] Compared with the prior art, the APP page loading speed measurement method, the device and the storage medium have the beneficial effect that the page loading end time and the page loading start time of a page picture are counted to accurately obtain the page loading time of user vision. The page view tree is traversed only once when the page loading time is obtained, and no performance loss is caused. BRIEF DESCRIPTION OF DRAWINGS
[0032] Figure 1 is a life cycle flowchart of page loading.
[0033] Figure 2 is a flowchart of the APP page loading speed measurement method;
[0034] Figure 3 is a flowchart of decoding callback in the APP page loading speed measurement method;
[0035] Figure 4 is a structural diagram of the APP page loading speed measurement device. DETAILED DESCRIPTION
[0036] The specific embodiments of the application are described in further detail below with reference to the drawings and examples. The following examples are used to illustrate the application, but are not used to limit the scope of the application.
[0037] Example 1:
[0038] In order to facilitate the public to better understand and implement the technical solutions of the application, the technical background of the application is described in more detail.
[0039] In the art, reference is made to Figure 1The life cycle flow chart of the page loading includes: page creation (onCreate), interface request initiation, first rendering, interface request end, page loading rendering and picture loading completion. The page creation is that the client opens the corresponding page in response to the user operation, for example, opening the shopping cart interface after clicking the shopping cart. Then the page is loaded and rendered according to the flow, and finally the loaded interface is displayed to the user.
[0040] In this loading process, the prior art often needs to constantly poll whether the display page is complete, so as to determine whether the page is loaded, which consumes a large amount of system performance and affects the user experience.
[0041] In order to reduce the consumption of system performance and improve the user experience, the application changes the polling method of the prior art and creatively proposes a speed measurement method which only needs to traverse the page view tree.
[0042] As shown in Figure 2 The application discloses a speed measurement method for APP page loading, which is applied to a mobile phone system and mainly includes the following steps:
[0043] Step S1: acquiring a page loading start time, traversing a page view tree when a page loading key frame is loaded, and acquiring all pictures needed to be displayed in a screen; the key frame is a rendering completion frame loaded after an interface request of the page is completed;
[0044] Step S2: adding a decoding callback to all pictures needed to be displayed in the screen and recording an end time of the decoding callback of all pictures needed to be displayed; the end time is a page loading end time;
[0045] Step S3: obtaining a page loading time according to the page loading end time and the page loading start time.
[0046] In step S1, the page loading start time is acquired, the page view tree is traversed when the page loading key frame is loaded, and all pictures needed to be displayed in the screen are acquired; the key frame is a rendering completion frame loaded after an interface request of the page is completed.
[0047] In this embodiment, the time when the system starts to generate the page in response to the user operation after the user operates the client can be directly acquired as the page loading start time. The page loading start time is a system time.
[0048] In this embodiment, when the page loading key frame is loaded, the page view tree is traversed, and the specific operation is as follows:
[0049] After the interface request of the page whose loading time needs to be counted is completed, a component code is inserted, and the component code is used to acquire view information and determine the page loading key frame.
[0050] When the page key frame is loaded, the page view tree is traversed.
[0051] In the embodiment, those skilled in the art can realize the above technical effects by using different programming languages according to the technical solutions disclosed in the present application.
[0052] In the embodiment, the ViewTree (an Android page view tree) is traversed to obtain pictures visible on the screen, i.e., pictures required to be displayed on the screen. In an optional implementation, the SimpleDreeView (a network picture library loading control) is used to obtain pictures required to be loaded for judging and measuring the page speed.
[0053] The page view tree is only traversed once when the page loading time is obtained, and no performance loss is caused.
[0054] Reference Figure 3 In step S2, all pictures required to be displayed on the screen are added with decoding callbacks, and the end time of decoding callback completion of all pictures required to be displayed is recorded; the end time is the page loading end time.
[0055] In the embodiment, the adding of decoding callbacks to all pictures required to be displayed on the screen and the recording of the end time of decoding callback completion of all pictures required to be displayed are specifically as follows:
[0056] The decoding callbacks are performed on all pictures required to be displayed on the screen one by one, and after the decoding callback of each picture is completed, the picture is set as having completed the decoding callback.
[0057] When all pictures are set as having completed the decoding callback, the end time of decoding callback completion of all pictures required to be displayed is recorded.
[0058] In the embodiment, decoding callbacks are added to pictures required to be used for judging and measuring the page speed (all pictures required to be displayed on the screen), and after the pictures are decoded, the pictures are set with a loading completion flag, which is used to finally count the picture loading completion time.
[0059] In step S3, the page loading end time and the page loading start time are used to obtain the page loading time.
[0060] In the embodiment, the obtaining of the page loading time according to the page loading end time and the page loading start time is specifically as follows:
[0061] The page loading end time is subtracted from the page loading start time to obtain the page loading time.
[0062] Since the page loading end time is determined according to the picture decoding time, the obtained page loading end time is more accurate, and thus the page loading end time and the page loading start time are counted to accurately obtain the page loading time of the user's vision.
[0063] Embodiment 2
[0064] With reference to Figure 4 On the basis of Embodiment 1, the application discloses a speed measuring device for APP page loading, comprising a first obtaining module 101, a second obtaining module 102 and a result output module 103.
[0065] The first obtaining module 101 is configured to obtain a page loading start time, and when a page loading key frame is loaded, a page view tree is traversed to obtain all pictures required to be displayed in a screen.
[0066] The second obtaining module 102 is configured to add a decoding callback to all pictures required to be displayed in the screen, and record an end time of completion of decoding callback of all pictures required to be displayed.
[0067] The result output module 103 is configured to obtain a page loading time according to the page loading end time and the page loading start time.
[0068] In this embodiment, when the page loading key frame is loaded, the page view tree is traversed, and specifically:
[0069] After an interface request of a page for which the page loading time is required to be counted is completed, a component code is inserted, and the component code is configured to obtain view information and determine the page loading key frame.
[0070] When the page loading key frame is loaded, the page view tree is traversed.
[0071] In this embodiment, the decoding callback is added to all pictures required to be displayed in the screen, and the end time of completion of decoding callback of all pictures required to be displayed is recorded, and specifically:
[0072] The decoding callback is added to all pictures required to be displayed in the screen one by one, and after the decoding callback of each picture is completed, the picture is set as having completed the decoding callback.
[0073] When all pictures are set as having completed the decoding callback, the end time of completion of decoding callback of all pictures required to be displayed is recorded.
[0074] In this embodiment, the page loading time is obtained according to the page loading end time and the page loading start time, and specifically:
[0075] Subtract the start time of page loading from the end time of page loading to get the page load time.
[0076] Example 2 is written based on Example 1, and Example 2 protects the speed measurement method of Example 1 from the perspective of the device. Therefore, those skilled in the art can understand the technical solution of Example 2 based on the technical features disclosed in Example 1, and therefore the explanation of the technical features in Example 1 will not be repeated.
[0077] Example 3:
[0078] The present invention also discloses a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the speed measurement method for loading the APP page as described in Embodiment 1.
[0079] In summary, compared with existing technologies, the advantages of this method, device, and storage medium for measuring app page loading speed are as follows: This invention can accurately obtain the user's perceived page loading time by statistically analyzing the end time of page image loading and the start time of page loading. Furthermore, this invention only requires traversing the page view tree once when obtaining the page loading time, resulting in no performance loss.
[0080] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and substitutions can be made without departing from the technical principles of the present invention, and these improvements and substitutions should also be considered within the scope of protection of the present invention.
Claims
1. A method for measuring the speed of APP page loading, characterized in that, include: The page load start time is obtained. After the API request for the page whose page load time needs to be calculated is completed, component code is inserted. The component code is used to obtain view information and determine the page load keyframe. When the page loads a keyframe, the page view tree is traversed to obtain all the images that need to be displayed on the screen. The keyframe is the rendering completion frame loaded after the page's API request is completed. Add decoding callbacks to all images that need to be displayed on the screen, and record the end time of the decoding callbacks for all images to be displayed; the end time is the page loading end time. The page load time is obtained based on the page load end time and page load start time.
2. The method for measuring the speed of APP page loading according to claim 1, characterized in that, The step of adding decoding callbacks to all images to be displayed on the screen and recording the end time of the decoding callbacks for all images to be displayed is as follows: Decode each image that needs to be displayed on the screen one by one. After the decoding callback of each image is completed, set the image as having completed the decoding callback. Once all images are set to have completed decoding callbacks, record the end time of the decoding callback completion for all images to be displayed.
3. The method for measuring the speed of APP page loading according to claim 1, characterized in that, The page load time is obtained based on the page load end time and page load start time, specifically as follows: Subtract the start time of page loading from the end time of page loading to get the page load time.
4. A speed measuring device for loading an APP page, characterized in that, include: The module consists of a first acquisition module, a second acquisition module, and a result output module. The first acquisition module is used to acquire the page loading start time. After the interface request of the page for which the page loading time needs to be statistically analyzed is completed, component code is inserted. The component code is used to acquire view information and determine the page loading key frame. When the page loads a key frame, the page view tree is traversed to acquire all the images that need to be displayed on the screen. The key frame is the rendering completion frame loaded after the page's interface request is completed. The second acquisition module is used to add decoding callbacks to all images to be displayed on the screen, and record the end time of the completion of the decoding callbacks for all images to be displayed; the end time is the page loading end time. The result output module is used to obtain the page load time based on the page load end time and the page load start time.
5. The speed measurement device for APP page loading according to claim 4, characterized in that, The step of adding decoding callbacks to all images to be displayed on the screen and recording the end time of the decoding callbacks for all images to be displayed is as follows: Decode each image that needs to be displayed on the screen one by one. After the decoding callback of each image is completed, set the image as having completed the decoding callback. Once all images are set to have completed decoding callbacks, record the end time of the decoding callback completion for all images to be displayed.
6. The speed measurement device for APP page loading according to claim 4, characterized in that, The page load time is obtained based on the page load end time and page load start time, specifically as follows: Subtract the start time of page loading from the end time of page loading to get the page load time.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the speed measurement method for APP page loading as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Page loading time length detection method and device, equipment and storage medium
CN110287441A