Network performance data acquisition method and apparatus, computer device, and storage medium
By obtaining the weight value and trigger time of the target element node to generate the peak time of batch rendering, and combining it with the end time of the HTTP request, the problem of cumbersome and inaccurate network performance data acquisition is solved, and high-quality data collection and user experience feedback are achieved.
Patent Information
- Application Number
- CN202210708595.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-22
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2042-06-22
AI Technical Summary
Existing methods for obtaining network performance data are cumbersome, the data is not accurate enough, and they cannot truly reflect the user experience.
By obtaining the weight value and trigger time of each target element node in the current page, the peak time of batch rendering is generated and compared with the end time of the HTTP request to determine network performance data.
It ensures the accuracy and consistency of network performance data, truly reflecting the user experience, and eliminates the need for redevelopment when adding new pages.
Smart Images

Figure CN114968746B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, computer device, and storage medium for acquiring network performance data. Background Technology
[0002] With the development of Web (World Wide Web) technology, related Web applications are becoming increasingly widespread. For example, in single-page web applications, the browser loads HTML, CSS, and JavaScript, dynamically generates element nodes (nodes), and renders the interface. Users then interact with the page. The time it takes for a user to interact with the page is network performance data (i.e., page loading speed). For Web applications, network performance data is related to user click-through rates and retention rates, indirectly affecting the company's production and operational efficiency.
[0003] Current methods for obtaining network performance data mainly include:
[0004] 1. Obtaining network performance data by manually tracking data points; In the manual tracking method, tracking points need to be added repeatedly for each new page, which is very cumbersome. In addition, the tracking point locations are not consistent (after the page loads or after the page data is loaded), resulting in inaccurate data.
[0005] 2. Use the browser's built-in performance function to obtain network performance data. This method calculates network performance data by subtracting the loadEventEnd (load event completion time) and navigationStart (unloading the previous document's end time) from the timing data set in the performance object. However, this method does not consider initialization API requests and page rendering, and the results do not accurately reflect the user experience. Summary of the Invention
[0006] This invention provides a method, apparatus, computer device, and storage medium for acquiring network performance data, aiming to solve the technical problems of existing methods for acquiring network performance data, such as cumbersome operation, inaccurate data, and inability to truly reflect user experience.
[0007] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0008] A method for acquiring network performance data, comprising:
[0009] Obtain the weight value of each target element node that has changed on the current page and the trigger time of each target element node, and generate the batch rendering peak time of the current page based on the weight value and trigger time of the target element node.
[0010] Obtain all HTTP requests for the current page and the end time of each request, and then obtain the last end time from the multiple end times;
[0011] The peak times of batch rendering are compared with the last end time to determine whether all peak times of batch rendering are before the last end time. If so, the time point closest to the last end time among the peak times of batch rendering is used as the network performance data of the current page; otherwise, the time point with the smallest absolute value closest to the last end time among the peak times of batch rendering is used as the network performance data of the current page.
[0012] The technical solution adopted in this embodiment of the invention further includes: obtaining the weight value of each changed target element node in the current page and the trigger time of each target element node includes:
[0013] The MutationObserver interface is used to monitor the target element node of the current page. When a change is detected in the target element node, it is determined whether the changed target element node is within the viewport. If it is within the viewport,
[0014] Calculate the weight value of each target element node within the viewport, and count the trigger time corresponding to each target element node to obtain the weight values and corresponding trigger times of n target element nodes, and generate the batch rendering time of the current page; the weight value is the depth of each target element node.
[0015] The technical solution adopted in this embodiment of the invention further includes: obtaining the peak time of batch rendering of the current page based on the weight value of the target element node and the trigger time includes:
[0016] Remove the 0-rendering time points from the batch rendering time to obtain the batch rendering peak time of the current page; the batch rendering peak time is the time point where all weight values are not 0.
[0017] The technical solution adopted in this embodiment of the invention further includes: obtaining all HTTP requests of the current page and the end time of each request specifically involves:
[0018] Sort all HTTP requests in ascending order based on the time they were initiated.
[0019] Based on the sorting results, starting from the first request, the time difference between the two requests is obtained by subtracting the end time of the previous request from the start time of the next request.
[0020] Determine if the time difference is greater than zero. If the time difference is greater than zero and less than a set time threshold, add the two requests to the first request group. If the time difference is greater than zero and greater than the set time threshold, add the latter request to the second request group. If the time difference is less than zero, use the former request as the decrement item for the next round. Continue in this manner until all HTTP requests are grouped.
[0021] The technical solution adopted in this embodiment of the invention further includes: obtaining the last end time from multiple end times specifically involves:
[0022] Obtain the HTTP request with the latest end time in the first request group, and take the end time of the HTTP request with the latest end time as the last end time.
[0023] The technical solution adopted in this embodiment of the invention further includes: specifically, using the time point closest to the last end time and with the smallest absolute value among the batch rendering peak times as the network performance data of the current page is as follows:
[0024] Calculate the absolute values of the previous and next rendering times that are closest to the last end time in the batch rendering peak time, compare the size of the two absolute values, and take the rendering time with the smallest absolute value as the network performance data of the current page.
[0025] Another technical solution adopted in this embodiment of the invention is: a network performance data acquisition device, comprising:
[0026] Rendering time acquisition module: used to acquire the weight value of each target element node that has changed in the current page and the trigger time of each target element node, and generate the batch rendering peak time of the current page based on the weight value and trigger time of the target element node;
[0027] Request time acquisition module: used to acquire all HTTP requests of the current page and the end time of each request, and to acquire the last end time from multiple end times;
[0028] Performance data acquisition module: Used to compare the peak times of batch rendering with the last end time, and determine whether all the peak times of batch rendering are before the last end time. If so, the time point closest to the last end time among the peak times of batch rendering is used as the network performance data of the current page; otherwise, the time point with the smallest absolute value closest to the last end time among the peak times of batch rendering is used as the network performance data of the current page.
[0029] The technical solution adopted in this embodiment of the invention further includes: the request time acquisition module obtaining the last end time from the end times specifically includes:
[0030] Sort all HTTP requests in ascending order according to their initiation time. Based on the sorting result, starting from the first request, subtract the end time of the previous request from the start time of the next request to obtain the time difference between the two requests. Determine if the time difference is greater than zero. If the time difference is greater than zero and less than a set time threshold, add the two requests to the first request group. If the time difference is greater than zero and greater than the set time threshold, add the next request to the second request group. If the time difference is less than zero, use the previous request as the subtraction item in the next round. Continue in this manner until all HTTP requests are grouped. Obtain the HTTP request with the latest end time in the first request group and use the end time of the latest end time of the HTTP request as the last end time.
[0031] Another technical solution adopted in this embodiment of the invention is: a computer device, the computer device comprising:
[0032] Memory containing executable program code;
[0033] The processor connected to the memory;
[0034] The processor calls the executable program code stored in the memory to execute the above-described network performance data acquisition method.
[0035] Another technical solution adopted in this embodiment of the invention is: a storage medium storing program instructions that can be executed by a processor, the program instructions being used to execute the above-described network performance data acquisition method.
[0036] The network performance data acquisition method, apparatus, computer device, and storage medium of this invention monitor changes in target element nodes. Based on the weight value of each changed target element node and its corresponding trigger time, the peak time of batch rendering for the current page is obtained. When a change in the HTTP request path is detected, the end time of the latest HTTP request is obtained and compared with the peak time of batch rendering. If the peak time is before the end time, the rendering time closest to the end time within the peak time is used as the network performance data for the current page. If the peak time is after the end time, the rendering time with the smallest absolute value closest to the end time within the peak time is used as the network performance data for the current page. This invention can effectively collect network performance data from all single-page applications, with consistent statistical dimensions, high data quality, and no need for redevelopment when adding new pages. Furthermore, this invention fully considers request and page rendering conditions, ensuring that the final network performance data accurately reflects the user experience. Attached Figure Description
[0037] Figure 1 This is a flowchart illustrating the network performance data acquisition method according to the first embodiment of the present invention;
[0038] Figure 2 This is a flowchart illustrating the network performance data acquisition method according to the second embodiment of the present invention;
[0039] Figure 3 This is a schematic diagram of the network performance data acquisition device according to an embodiment of the present invention;
[0040] Figure 4 This is a schematic diagram of the computer device structure according to an embodiment of the present invention;
[0041] Figure 5 This is a schematic diagram of the storage medium structure according to an embodiment of the present invention. Detailed Implementation
[0042] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0043] The terms "first," "second," and "third" used in this invention are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified. All directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of this invention are only used to explain the relative positional relationships and movements between components in a specific orientation (as shown in the figures). If the specific orientation changes, the directional indications also change accordingly. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.
[0044] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0045] Please see Figure 1 This is a flowchart illustrating the network performance data acquisition method according to the first embodiment of the present invention. The network performance data acquisition method according to the first embodiment of the present invention includes the following steps:
[0046] S100: Obtain the weight value of each target element node that has changed on the current page and the trigger time of each target element node, and generate the batch rendering peak time of the current page based on the weight value and trigger time of the target element node.
[0047] In this step, the MutationObserver interface in the DOM specification is used to monitor changes such as the addition, deletion, or modification of target element nodes on the current page. When a change is detected in a target element node, the weight value of each changed target element node is calculated, and the trigger time corresponding to each target element node is counted. Based on the weight value and trigger time of each target element node, the peak time of batch rendering of the current page is obtained. The specific calculation method of the target element node weight value is as follows: for added, modified, or deleted target element nodes, the depth of each target element node (the target element node is a tree-like data structure) is recursively counted, and the depth of each target element node is used as its corresponding weight value. The batch rendering time includes the weight value of each target element node and its corresponding trigger time.
[0048] Furthermore, when a change is detected in a target element node, it is necessary to determine whether the changed target element node is within the viewport. If it is within the viewport, the weight value of the target element node and its corresponding trigger time are calculated, resulting in the weight values and corresponding trigger times of n target element nodes, thus generating the peak time for batch rendering of the current page. If the changed target element node is not within the viewport, since the rendering of content outside the viewport is imperceptible to the user, there is no need to calculate the weight value of that element node.
[0049] S110: Get all HTTP requests for the current page and the end time of each request, and get the last end time from the end times;
[0050] In this step, all HTTP requests for the current page are obtained and sorted in ascending order according to their initiation time. Based on the sorting result, starting from the first request, the time difference between the start time of the next request and the end time of the previous request is subtracted from the start time of the next request. All HTTP requests with a time difference less than a set time threshold are added to the first request group. The HTTP request with the latest end time in the first request group is obtained and its end time is taken as the last end time.
[0051] S120: Compare the peak times of batch rendering with the last end time to determine whether the peak times of batch rendering are all before the last end time. If so, execute S130; otherwise, execute S140.
[0052] S130: Use the time point closest to the last end time in the peak time of batch rendering as the network performance data of the current page;
[0053] S140: Use the time point with the smallest absolute value that is closest to the last end time in the batch rendering peak time as the network performance data of the current page.
[0054] Based on the above, the network performance data acquisition method of the first embodiment of the present invention fully considers request and page rendering conditions, enabling the final network performance data to truly reflect the user's experience. The present invention can effectively collect network performance data from all single-page applications, with consistent statistical dimensions, high data quality, and no need for redevelopment when adding new pages.
[0055] Please see Figure 2 This is a flowchart illustrating the network performance data acquisition method according to the second embodiment of the present invention. The network performance data acquisition method according to the second embodiment of the present invention includes the following steps:
[0056] S200: Monitor the target element nodes of the current page when the user first enters the page;
[0057] In this step, the MutationObserver interface from the DOM specification is used to monitor changes such as the addition, deletion, or modification of target element nodes on the current page. The MutationObserver interface can asynchronously execute callbacks when the DOM is modified. Using the MutationObserver interface, you can observe parts or elements of the DOM tree, and you can also observe changes in element attributes, child nodes, text, or any combination of the first three.
[0058] S210: When a change in a target element node is detected, calculate the weight value of each changed target element node and count the trigger time corresponding to each target element node. Based on the weight value and trigger time of each target element node, obtain the batch rendering time of the current page.
[0059] In this step, the target element node weight value is calculated as follows: for newly added, modified, or deleted target element nodes, the depth of each target element node (the target element node is a tree-like data structure) is recursively calculated, and the depth of each target element node is used as its corresponding weight value. The batch drawing time includes the weight value of each target element node and its corresponding trigger time.
[0060] Furthermore, when a change is detected in a target element node, it is necessary to determine whether the changed target element node is within the viewport. If it is within the viewport, the weight value of the target element node and its corresponding trigger time are calculated, resulting in the weight values and corresponding trigger times of n target element nodes, which are then used to generate the batch rendering time for the current page. If the changed target element node is not within the viewport, since the rendering of content outside the viewport is imperceptible to the user, there is no need to calculate the weight value of that element node.
[0061] S220: Remove the 0-rendering time points in the batch rendering time to obtain the peak batch rendering time of the current page;
[0062] In this step, the peak time for batch rendering is the time point when all weight values are not 0.
[0063] S230: Obtain all HTTP requests for the current page, sort all HTTP requests in ascending order according to the initiation time of each HTTP request, and based on the sorting result, starting from the first request, subtract the end time of the previous request from the start time of the next request to obtain the time difference between the two requests, and add all HTTP requests with a time difference less than the set time threshold to the first request group.
[0064] In this step, an HTTP (Hypertext Transfer Protocol) request refers to a request message from the client to the server. The obtained HTTP requests include AJAX requests and requests for static resources. This embodiment of the application utilizes the Performance Resource Timing interface to monitor HTTP requests. The Performance Resource Timing interface can retrieve and analyze detailed network timing data related to loading application resources. The Performance Resource Timing interface uses the high-resolution timestamps property to create a resource loading timeline for network events, such as redirect start and end times, fetch start times, DNS lookup start and end times, and response start and end times.
[0065] Furthermore, the HTTP request grouping method is as follows: First, all HTTP requests are sorted in ascending order according to their initiation time. Then, based on the sorting result, starting from the first request, the start time of the next request is subtracted from the end time of the previous request to obtain the time difference between the two requests. It is then determined whether the time difference is greater than zero. If the time difference is greater than zero and less than a set time threshold, the two requests are added to the first request group. If the time difference is greater than zero and greater than the set time threshold, the next request is added to the second request group. If the time difference is less than zero, the previous request in this round is used as the subtraction item for the next round of comparison. That is, the start time of the previous request in this round is subtracted from the end time of the previous request to obtain the time difference between the two requests in the next round. The time difference is then checked again to see if it is greater than zero. If the time difference is greater than zero and less than the set time threshold, the two requests are added to the first request group. This process continues until all HTTP requests are grouped. Since the fastest human reaction time is 0.2s, as a preferred embodiment, this application sets the time threshold to 0.2s. The specific time threshold can be set according to the actual application scenario.
[0066] S240: Obtain the latest HTTP request in the first request group, take the end time of the latest HTTP request as the last end time, and compare the last end time with the peak time of the current page's batch rendering. Determine whether the peak times of the batch rendering are all before the last end time. If the peak times of the batch rendering are all before the last end time, execute S250; otherwise, execute S260.
[0067] S250: Use the rendering time closest to the last end time in the batch rendering peak time as the network performance data of the current page;
[0068] In this step, if the peak times of batch rendering all occur before the last end time of all HTTP requests, it indicates that no page rendering occurs after the requests end. The rendering time closest to the last end time among the peak times of batch rendering is taken as the network performance data for the current page. This network performance data represents the interface loading speed. After the URL is accessed, the page needs to go through processes such as fetching static resources (including HTML, CSS, and JavaScript), rendering, executing JavaScript, obtaining necessary initialization data, executing JavaScript again, and re-rendering before the user can perform actual page operations. The time the user can interact with the page is the network performance data.
[0069] S260: Calculate the absolute values of the previous and next rendering times that are closest to the last end time in the batch rendering peak time, compare the size of the two absolute values, and take the rendering time with the smallest absolute value as the network performance data of the current page.
[0070] Based on the above, the network performance data acquisition method of the second embodiment of the present invention monitors changes in target element nodes through the MutationObserver interface. It obtains the batch rendering peak time of the current page based on the weight value of each changed target element node and its corresponding trigger time. When a change in the HTTP request path is detected, it obtains the end time of the latest HTTP request and compares this end time with the batch rendering peak time. If the batch rendering peak time is before this end time, the rendering time closest to this end time within the batch rendering peak time is used as the network performance data of the current page. If the batch rendering peak time is after this end time, the rendering time closest to this end time and with the smallest absolute value within the batch rendering peak time is used as the network performance data of the current page. This invention can effectively collect network performance data from all single-page applications, with consistent statistical dimensions, high data quality, and no need for repeated development when adding new pages. Furthermore, this invention fully considers request and page rendering conditions, ensuring that the final network performance data accurately reflects the user's experience.
[0071] In an optional implementation, the results of the network performance data acquisition method can also be uploaded to the blockchain.
[0072] Specifically, based on the results of the network performance data acquisition method, corresponding digest information is obtained. Specifically, the digest information is obtained by hashing the results of the network performance data acquisition method, for example, using the SHA256s algorithm. Uploading the digest information to the blockchain ensures its security and fairness and transparency to users. Users can download the digest information from the blockchain to verify whether the results of the network performance data acquisition method have been tampered with. The blockchain referred to in this example is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. A blockchain is essentially a decentralized database, a chain of data blocks linked using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0073] Please see Figure 3 This is a schematic diagram of the network performance data acquisition device according to an embodiment of the present invention. The network performance data acquisition device 30 according to an embodiment of the present invention includes:
[0074] Rendering time acquisition module 31: used to acquire the weight value of each target element node that has changed in the current page and the trigger time of each target element node, and generate the batch rendering peak time of the current page based on the weight value and trigger time of the target element node.
[0075] Request time acquisition module 32: used to obtain all HTTP requests for the current page and the end time of each request, and to obtain the last end time from multiple end times;
[0076] Performance data acquisition module 33: It is used to compare the peak time of batch rendering with the last end time to determine whether the peak time of batch rendering is before the last end time. If so, the time point closest to the last end time among the peak times of batch rendering is used as the network performance data of the current page; otherwise, the time point with the smallest absolute value closest to the last end time among the peak times of batch rendering is used as the network performance data of the current page.
[0077] The network performance data acquisition device of this invention monitors changes in target element nodes through the MutationObserver interface. Based on the weight value of each changed target element node and its corresponding trigger time, it obtains the peak time of batch rendering for the current page. When a change in the HTTP request path is detected, it obtains the end time of the latest HTTP request and compares it with the peak time of batch rendering. If the peak time is before the peak time, the rendering time closest to the peak time is used as the network performance data for the current page. If the peak time is after the peak time, the rendering time with the smallest absolute value closest to the peak time is used as the network performance data for the current page. This invention can effectively collect network performance data from all single-page applications, with consistent statistical dimensions, high data quality, and no need for redevelopment when adding new pages. Furthermore, this invention fully considers request and page rendering conditions, ensuring that the final network performance data accurately reflects the user experience.
[0078] Please see Figure 4 This is a schematic diagram of a computer device structure according to an embodiment of the present invention. The computer device 50 includes:
[0079] Memory 51 storing executable program code;
[0080] Processor 52 connected to memory 51;
[0081] The processor 52 is used to call the executable program code stored in the memory 51 and perform the following steps: obtain the weight value of each changed target element node in the current page and the trigger time of each target element node, and generate the batch rendering peak time of the current page according to the weight value and trigger time of the target element node; obtain all HTTP requests of the current page and the end time of each request, and obtain the last end time from multiple end times; compare the batch rendering peak time with the last end time, and determine whether the batch rendering peak time is before the last end time. If so, take the time point closest to the last end time in the batch rendering peak time as the network performance data of the current page; otherwise, take the time point closest to the last end time and with the smallest absolute value in the batch rendering peak time as the network performance data of the current page.
[0082] The processor 52 can also be referred to as a CPU (Central Processing Unit). The processor 52 may be an integrated circuit chip with signal processing capabilities. The processor 52 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor.
[0083] Please see Figure 5 , Figure 5This is a schematic diagram of the storage medium according to an embodiment of the present invention. The storage medium of this embodiment stores a program file 61 capable of implementing the following steps: obtaining the weight value of each changed target element node in the current page and the trigger time of each target element node; generating a batch rendering peak time of the current page based on the weight value and trigger time of the target element node; obtaining all HTTP requests of the current page and the end time of each request, and obtaining the last end time from multiple end times; comparing the batch rendering peak time with the last end time, determining whether all batch rendering peak times are before the last end time; if so, using the time point closest to the last end time among the batch rendering peak times as the network performance data of the current page; otherwise, using the time point closest to the last end time among the batch rendering peak times and with the smallest absolute value as the network performance data of the current page. The program file 61 can be stored in the aforementioned storage medium in the form of a software product, including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage media include: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks or optical disks, and other media that can store program code, or terminal devices such as computers, servers, mobile phones, and tablets.
[0084] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, apparatuses, or units, and may be electrical, mechanical, or other forms.
[0085] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units described above can be implemented in hardware or as software functional units. The above are merely embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A network performance data acquisition method characterized by comprising: The method comprises the following steps: obtaining the weight value of each changed target element node in the current page and the triggering time of each target element node, and generating the batch rendering peak time of the current page according to the weight value and the triggering time of the target element node; obtaining all http requests of the current page and the end time of each request, and obtaining the last end time from multiple end times; the http request includes a request message from the client to the server; the specific method of obtaining all http requests of the current page and the end time of each request is as follows: sorting all http requests in ascending order according to the request initiation time; based on the sorting result, starting from the first request, subtracting the end time of the previous request from the start time of the next request to obtain the time difference between the two requests; judging whether the time difference is greater than zero; if the time difference is greater than zero and less than a set time threshold, the two requests are added to the first request group; if the time difference is greater than zero and greater than the set time threshold, the next request is added to the second request group; if the time difference is less than zero, the previous request is used as the next round of subtrahend; and the above steps are repeated until the grouping of all http requests is completed; comparing the batch rendering peak time with the last end time to determine whether the batch rendering peak time is before the last end time; if yes, the time point closest to the last end time in the batch rendering peak time is taken as the network performance data of the current page; otherwise, the time point closest to the last end time and having the smallest absolute value in the batch rendering peak time is taken as the network performance data of the current page.
2. The network performance data acquisition method according to claim 1, characterized by, The method of obtaining the weight value of each changed target element node in the current page and the triggering time of each target element node comprises the following steps: monitoring the target element node of the current page using the MutationObserver interface, and when the target element node is found to be changed, determining whether the changed target element node is in the window; calculating the weight value of each target element node in the window, and counting the triggering time corresponding to each target element node to obtain the weight value and the corresponding triggering time of n target element nodes, and generating the batch rendering time of the current page; the weight value is the depth of each target element node.
3. The network performance data acquisition method according to claim 2, characterized by, The method of obtaining the weight value of each changed target element node in the current page and the triggering time of each target element node comprises the following steps: eliminating the time point of 0 rendering in the batch rendering time to obtain the batch rendering peak time of the current page; the batch rendering peak time is all time points with a weight value of 0.
4. The network performance data collection method of claim 1, wherein, The specific method of obtaining the last end time from multiple end times is as follows: obtaining the http request with the latest end time in the first request group, and taking the end time of the http request with the latest end time as the last end time.
5. The network performance data acquisition method according to claim 4, characterized by, The time point closest to the last end time and having the minimum absolute value in the batch rendering peak time is taken as the network performance data of the current page. The absolute values of a previous rendering time and a next time closest to the last end time in the batch rendering peak time are calculated respectively, and the absolute value of the rendering time is compared to determine the rendering time with the minimum absolute value as the network performance data of the current page.
6. A network performance data acquisition apparatus characterized by comprising: The method comprises: a rendering time acquisition module configured to acquire a weight value of each changed target element node in a current page and a trigger time of each target element node, and generate a batch rendering peak time of the current page according to the weight value and the trigger time of the target element node; a request time acquisition module configured to acquire all http requests of the current page and an end time of each request, and acquire a last end time from the end time; the http requests comprise request messages from a client to a server; the request time acquisition module acquires the last end time from the end time, specifically including: sorting all the http requests in ascending order according to a request initiation time; based on the sorting result, starting from a first request, a time difference between two requests is obtained by subtracting an end time of a previous request from a start time of a next request; it is determined whether the time difference is greater than zero; if the time difference is greater than zero and less than a set time threshold, the two requests are added to a first request group; if the time difference is greater than zero and greater than the set time threshold, the next request is added to a second request group; if the time difference is less than zero, the previous request is taken as a subtrahend in the next round; the process is repeated until the grouping of all the http requests is completed; an http request with the latest end time in the first request group is acquired, and the end time of the http request with the latest end time is taken as the last end time; a performance data acquisition module configured to compare the batch rendering peak time with the last end time, determine whether the batch rendering peak time is before the last end time, and if so, take a time point closest to the last end time in the batch rendering peak time as the network performance data of the current page; otherwise, take a time point closest to the last end time and having the minimum absolute value in the batch rendering peak time as the network performance data of the current page.
7. A computer device, comprising: The computer device comprises: a memory storing executable program codes; a processor connected with the memory; the processor invokes the executable program codes stored in the memory to execute the network performance data acquisition method according to any one of claims 1-5.
8. A storage medium, characterized by Executable program instructions executable by a processor are stored, and the program instructions are used to execute the network performance data acquisition method according to any one of claims 1-5.
Citation Information
Patent Citations
Method and device for counting interaction time of single-page application and electronic equipment
CN114254222A