Performance analysis method and device of equipment, electronic equipment and storage medium
By acquiring information about the target application from the target device and configuring permissions, the problem of incompatibility between performance analysis tools and devices is solved, enabling cross-device performance data collection and improving application development efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2024-12-02
- Publication Date
- 2026-06-02
AI Technical Summary
In existing technologies, performance analysis tools are not compatible with some types of devices, making it impossible to collect performance data for the corresponding types of devices, increasing the difficulty of analysis and affecting the development efficiency of applications.
On the target device, by obtaining the application information of the target application and configuring permissions, the performance analysis program can access the device system as the target application and collect performance data.
It achieves compatibility between performance analysis methods and various types of devices, reduces the difficulty of performance data analysis for different types of devices, and improves the development efficiency of applications.
Smart Images

Figure CN122132267A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for analyzing the performance of a device. Background Technology
[0002] After application development is complete, performance acceptance can be performed on various types of devices. Specifically, this involves running the application on different devices and collecting performance data using performance analysis tools during runtime. This data is then used to optimize the application. However, in some scenarios, performance analysis tools may not function correctly on certain types of devices, indicating incompatibility. In such cases, performance data will be collected from devices compatible with the performance analysis tool, and the application will be optimized based on this data. However, since the reference data for application optimization does not cover devices incompatible with the performance analysis tool, the performance data from compatible devices may not be representative of the performance data from incompatible devices. This makes analyzing the performance data of incompatible devices more difficult and impacts development efficiency. Summary of the Invention
[0003] The technical problem to be solved by this application is to provide a device performance analysis method, apparatus, electronic device and storage medium that can reduce the difficulty of analyzing performance data of devices that are not compatible with performance analysis tools and improve the development efficiency of application programs.
[0004] To address the aforementioned technical problems, this application provides a method for analyzing the performance of a device, comprising:
[0005] During the execution of the target application on the target device, the target application information of the target application is obtained when the performance analysis program does not have performance data access permissions; the performance analysis program is a program independent of the target application and used for performance data collection; the performance data access permissions are the permissions of the target device to access the performance data of the target device from the system of the target device during the execution of the target application on the target device.
[0006] Based on the target application information, the performance analysis program is configured with permissions to obtain a configured performance analysis program; the configured performance analysis program can access the performance data in the target device's system as the target application.
[0007] Based on the configured performance analysis program, data is collected during the operation of the target application to obtain the performance data of the target device.
[0008] On the other hand, embodiments of this application provide a device performance analysis apparatus, including:
[0009] The application information acquisition module is used to acquire target application information of the target application during the operation of the target application on the target device, when the performance analysis program does not have performance data access permissions; the performance analysis program is a program independent of the target application and used for performance data collection; the performance data access permissions are the permissions of the target device to access the performance data of the target device from the system of the target device during the operation of the target application on the target device.
[0010] The permission configuration module is used to configure the permissions of the performance analysis program based on the target application information to obtain the configured performance analysis program; the configured performance analysis program can access the performance data in the system of the target device as the target application.
[0011] The data acquisition module is used to collect data during the operation of the target application based on the configured performance analysis program, and obtain the performance data of the target device.
[0012] On the other hand, this application provides an electronic device including a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the device performance analysis method as described above.
[0013] On the other hand, this application provides a computer storage medium storing at least one instruction or at least one program, wherein the at least one instruction or at least one program is loaded by a processor and executed as described above regarding the device performance analysis method.
[0014] On the other hand, this application provides a computer program product including computer instructions stored in a computer-readable storage medium; a processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the above-described device performance analysis method.
[0015] Implementing the embodiments of this application has the following beneficial effects:
[0016] This application, during the execution of a target application on a target device, if the performance analysis program lacks access permissions to the target device system's performance data, can obtain the target application information of the target application and configure permissions for the performance analysis program based on the target application information. This allows the configured performance analysis program to access the performance data in the target device system as the target application, thereby collecting the target device's performance data. This solves the problem in existing technologies where performance analysis tools are incompatible with some types of devices, thus preventing the collection of performance data from those types of devices. It achieves compatibility between performance analysis methods and various types of devices, reduces the difficulty of analyzing performance data from different types of devices, and improves the development efficiency of applications. Attached Figure Description
[0017] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the implementation environment provided in the embodiments of this application;
[0019] Figure 2 This is a flowchart of the device performance analysis method provided in the embodiments of this application;
[0020] Figure 3 This is a flowchart of the method for obtaining target application information provided in the embodiments of this application;
[0021] Figure 4 This is a flowchart of a method for analyzing the runtime information of an application unit in a single data frame, as provided in an embodiment of this application.
[0022] Figure 5 This is a performance analysis chart corresponding to each data frame provided in the embodiments of this application;
[0023] Figure 6 This is a schematic diagram of the performance analysis process provided in the embodiments of this application;
[0024] Figure 7 This is a schematic diagram of the performance analysis device of the equipment provided in the embodiments of this application;
[0025] Figure 8 This is a schematic diagram of an electronic device structure provided in an embodiment of this application. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. 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 server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0028] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0029] It is understood that in the specific embodiments of this application, data such as user information are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0030] Please see Figure 1 The illustration shows an implementation environment provided in the embodiments of this application. The implementation environment may include at least one target device 110, an application server 120, and an analysis terminal 130. The target device 110 and the application server 120 can communicate with each other via a network, and the target device 110 and the analysis terminal 130 can communicate with each other via a network.
[0031] Specifically, the target device 110 may have a target application installed, allowing it to run on the target device 110. If performance data of the target device 110 needs to be analyzed during the operation of the target application, a performance analysis program can be used to collect the performance data of the target device during the operation of the target application. The application server 120 can provide background services for the target application, receive data requests sent by the target application through the target device 110, and send the requested application data to the target application through the target device 110. Furthermore, the performance analysis program can be configured in the analysis terminal 130, and the configured performance analysis program can be pushed to the target device 110. The analysis terminal 130 can also receive performance data collected by the performance analysis program on the target device 110, analyze the received performance data to obtain performance analysis results, and optimize the target application based on the performance analysis results so that the target application can better adapt to the target device.
[0032] The target device 110 can communicate with the application server 120 based on a browser / server (B / S) or client / server (C / S) model. The target device 110 may include physical devices such as smartphones, tablets, laptops, digital assistants, smart wearable devices, and in-vehicle terminals; the analysis terminal 130 may be a physical device such as a tablet, laptop, or server. The operating system running on the target device 110 in this embodiment may include, but is not limited to, Android, iOS, Linux, and Windows.
[0033] The application server 120 and the target device 110 can establish a communication connection via wired or wireless means. The application server 120 may include a stand-alone server, a distributed server, or a server cluster consisting of multiple servers, wherein the server may be a cloud server.
[0034] To address the challenge of analyzing performance data from devices incompatible with performance analysis tools, which hinders R&D efficiency in existing technologies, this application provides a method for device performance analysis. The execution entity of this method can be the aforementioned analysis terminal. (See also...) Figure 2 The method may include:
[0035] S210. During the execution of the target application on the target device, if the performance analysis program does not have performance data access permissions, obtain the target application information of the target application; the performance analysis program is a program independent of the target application and used for performance data collection; the performance data access permissions are the permissions of the target device to access the performance data of the target device from the system of the target device during the execution of the target application on the target device.
[0036] In this embodiment, the target application can be a game application, an instant messaging application, a short video application, etc. After the target application is developed, performance acceptance testing can be performed. Specifically, the target application can be installed on different types of devices to collect performance data when running the target application on different types of devices. This facilitates optimization and iteration of the target application based on the performance data, so that the target application can better adapt to different types of devices. For example, on some types of devices, there are time-consuming functions in the target application. Therefore, during the optimization and iteration process of the target application, it is necessary to optimize these time-consuming functions.
[0037] Specifically, performance data of various types of devices running a target application can be collected through a performance analysis program. For device types compatible with the performance analysis program, these devices have performance data access permissions, meaning they have the authority to access the target device's performance data from its system while the target application is running. Therefore, the performance analysis program can directly collect the target device's performance data from its system during the target application's operation. For device types incompatible with the performance analysis program, these devices do not have performance data access permissions, meaning they do not have the authority to access the target device's performance data from its system while the target application is running. The performance analysis program can then obtain the target application's information to enable subsequent permission configuration. This target application information can include identifiers, permissions, and identity information representing the target application. The target application and the performance analysis program are independent programs. The performance analysis program can be integrated into a performance analysis tool, which analyzes the collected performance data and obtains corresponding results. The performance analysis tool can be a third-party general-purpose analysis tool or a self-developed analysis tool adapted to the target application.
[0038] Further, please refer to Figure 3It illustrates a method for obtaining target application information. The execution entity of this method can be the aforementioned analysis terminal, and specifically, the target application information can be obtained based on a performance analysis program. This method may include:
[0039] S310. Obtain the installation package identifier corresponding to the target application.
[0040] If the target device needs to install the target application, the target application's installation package can be downloaded first, and then the target application can be installed on the target device based on the target installation package; here, the installation package identifier is the identifier of the target installation package, which can be the name of the target installation package, the label information of the installation package, etc.
[0041] S320. Obtain the process data of the target application based on the installation package identifier.
[0042] During the execution of the target application, there will be corresponding process data; the process data of the target application can be obtained based on the installation package identifier.
[0043] S330. Obtain the target application information from the process data.
[0044] The target application information can specifically be the program identifier of the target application, such as UID (Unique Identifier). Specifically, you can obtain the process data of the target application by using the code `pm list packages -U|grep packageName`, where packageName is the installation package identifier. You can also obtain the process output information stream by using the code `process.getInputStream`, and then parse the UID field from this information stream using `line.contains("uid:")` to obtain the UID data of the specific application.
[0045] In this embodiment, the process data of the target application can be obtained through the installation package identifier of the target application, and then the target application information can be obtained from the process data. Since the process data of the target application is generated during the running process, the process data can include various specific information of the target application and is easy to obtain, thereby improving the convenience and efficiency of obtaining the target application information.
[0046] S220. Configure permissions for the performance analysis program based on the target application information to obtain a configured performance analysis program; the configured performance analysis program can access the performance data in the target device's system as the target application.
[0047] The target application information is the program identifier of the target application; therefore, the step of configuring permissions for the performance analysis program based on the target application information to obtain the configured performance analysis program includes:
[0048] The performance analysis program is configured with permissions based on the program identifier of the target application to obtain a configured performance analysis program; the configured performance analysis program has the program identifier of the target application.
[0049] Specifically, by executing `setuidgid`, the program identifier UID data of the target application can be set to the UID of the performance analysis program, thereby ensuring that the performance analysis program and the target application are under the same UID, thus avoiding various access permission failure issues.
[0050] The `setuidgid` command is used to set special permissions for files, allowing users to execute programs with a specific identity without changing their actual identity. This helps improve system administration and security, especially useful when programs need to run with specific permissions. With `setuidgid`, a program can run with specific permissions, meaning it can access resources within that user's permission scope, thus avoiding performance bottlenecks caused by insufficient permissions. When a program runs as a specific user, the system doesn't need to perform complex permission checks for every operation, reducing system overhead and improving execution efficiency. Because the program runs with a specific identity, it can access and manipulate resources under that user's permissions more efficiently, reducing resource access latency and errors. In situations where programs need to run with specific permissions, `setuidgid` can significantly improve program execution efficiency and security. For example, a game performance analysis program might need to access certain system data or perform specific system operations. By setting `setuidgid`, the program can run with the game's permissions, avoiding performance issues caused by insufficient permissions. This ensures that the performance analysis program can complete its tasks efficiently and securely, while reducing waste of system resources and errors.
[0051] S230. Based on the configured performance analysis program, data is collected during the operation of the target application to obtain the performance data of the target device.
[0052] The configured performance analysis suite has the permissions of the target application, thus having the permission to access the performance data of the target device from the system of the target device while the target application is running. In other words, it can collect data and obtain the performance data of the target device during the operation of the target application.
[0053] This application, during the execution of a target application on a target device, if the performance analysis program lacks access permissions to the target device system's performance data, can obtain the target application information of the target application and configure permissions for the performance analysis program based on the target application information. This allows the configured performance analysis program to access the performance data in the target device system as the target application, thereby collecting the target device's performance data. This solves the problem in existing technologies where performance analysis tools are incompatible with some types of devices, thus preventing the collection of performance data from those types of devices. It achieves compatibility between performance analysis methods and various types of devices, reduces the difficulty of analyzing performance data from different types of devices, and improves the development efficiency of applications.
[0054] In this embodiment, the target application includes at least one target application unit, and the performance data of the target device includes the total time consumed by the target device in each target application unit during the execution of the target application. The target application unit can be a functional function contained within the target application, and the target application can include multiple functional functions, thus the process of running the target application can be the process of running multiple functional functions. Correspondingly, the total time consumed by the target device in each target application unit can be the total time consumed by the target device when executing each functional function. See also... Figure 4 It illustrates a method for analyzing the time consumption information of running application units in a single data frame, which may include:
[0055] S410. During the operation of the target application, obtain the call timestamp of each call to the graphics rendering function; call the graphics rendering function once for each data frame rendered.
[0056] During the execution of the target application, the graphics rendering function is invoked once for each data frame rendered. For example, the graphics rendering function can be invoked when rendering the current data frame; it can also be invoked when rendering the next data frame is needed after rendering the current data frame, and so on. Each time the graphics rendering function is invoked, the correspondence between the current data frame and the timestamp of the call to the graphics rendering function can be recorded. The timestamp of each invocation of the graphics rendering function can be obtained using a performance analysis program.
[0057] S420. Determine the time interval corresponding to each data frame based on the call timestamp of each call to the graphics rendering function; the time interval corresponding to each data frame is determined based on the call timestamp of each data frame and the call timestamp of the next data frame.
[0058] The time interval for each data frame can be determined by the call timestamp of the graphics rendering function in each data frame. The start time of the time interval for each data frame is the call timestamp when the graphics rendering function is first called in that data frame, and the end time of the time interval for each data frame is the call timestamp when the graphics rendering function is first called in the next data frame. That is, the call timestamp of the current data frame is the end time of the call of the previous data frame, and the end time of the call of the current data frame is the call timestamp when the graphics rendering function is first called in the next data frame. For example, if data frames 1 and 2 are two adjacent data frames, and data frame 1 calls the graphics rendering function first, and then data frame 2 calls the graphics rendering function, the call timestamp for data frame 1 is ta, the call timestamp for data frame 2 is tb, and the corresponding time interval for data frame 1 is [ta, tb].
[0059] S430. Determine from the total time consumption information the running application unit that runs within the time interval corresponding to each data frame and the time consumption information of the running application unit; the running application unit is at least one of the target application units.
[0060] The total time consumption information may include the total time consumption information of each target application unit, and accordingly, the target application unit running in the data frame and the time consumption information of the target application unit can be determined within the duration of each data frame.
[0061] Specifically, the total time consumption information includes the time consumption information of the at least one target application unit on the runtime timeline; the runtime timeline corresponds to the running process of the target application; each target application unit may run once or multiple times during the running process of the target application. If a target application unit runs once during the running process of the target application, a corresponding segment of time consumption information can be recorded on the runtime timeline; if a target application unit runs multiple times during the running process of the target application, multiple segments of time consumption information can be recorded on the runtime timeline. Each segment of time consumption information corresponds to the start and end times of the target application unit on the runtime timeline, and the time interval between the start and end times is the time consumption information of the target application unit in one running process.
[0062] Accordingly, determining the running application unit and its time consumption information within the time interval corresponding to each data frame from the total time consumption information includes:
[0063] Based on the call timestamp corresponding to each data frame and the call timestamp corresponding to the next data frame, a target interval corresponding to the time interval of each data frame is determined on the running time axis;
[0064] The running application units running within the target interval on the running time axis and the time consumption information of the running application units are determined as the running application units running within the time interval corresponding to each data frame and the time consumption information of the running application units.
[0065] The next data frame after each data frame is the data frame adjacent to each data frame and rendered after each data frame. The runtime timeline can include time point scale information. The time start point of the time interval corresponding to each data frame is the call timestamp of each data frame, and the time end point is the call timestamp of the next data frame. Thus, the start time scale corresponding to the call timestamp of each data frame and the end time scale corresponding to the call timestamp of the next data frame can be found on the runtime timeline. By extracting the application units involved between the start time scale and the end time scale and the corresponding time consumption information, the application units running in a time interval of each data frame and the corresponding time consumption information can be determined.
[0066] For example, the starting time point of the runtime timeline is t1, and the ending time point of the runtime timeline is tn. Data frame 1 and data frame 2 are two adjacent data frames. Data frame 1 calls the graphics rendering function first, and data frame 2 calls the graphics rendering function next. The call timestamp corresponding to data frame 1 is ta, and the call timestamp corresponding to data frame 2 is tb. The corresponding time interval for data frame 1 is [ta, tb], where ta ≥ t1 and tb ≤ tn. Accordingly, the time scale corresponding to ta and the time scale corresponding to tb can be determined on the runtime timeline. This enables the extraction of the application unit running between ta and tb and the corresponding time consumption information from the runtime timeline.
[0067] Specifically, after obtaining the total time consumed by the target device in each target application unit during the operation of the target application, the information can be saved to a report file; then the report file is read and parsed line by line: report_data = file.readlines(); match = pattern.search(line) uses regular expressions to match the calls to the image rendering function eglSwapBuffers, and records the timestamp of each call and saves it to swap_buffers_times; then the time interval between each eglSwapBuffers call is calculated; based on the final time interval, the performance data of each time interval can be extracted, which is convenient for R&D personnel to determine the stuttering function information of each frame.
[0068] In this embodiment, based on obtaining the overall time consumption information of each application unit during the execution of the target application, the analysis of the time consumption information of the running application units in a single data frame can be further realized. This refines the granularity of the analysis of the execution time consumption information and facilitates the analysis of the time consumption information of the application units in each data frame. Specifically, by using the timestamp of the graphics rendering function called during the processing of each data frame, the time interval of each data frame can be determined. Then, the time consumption information of the application units within a single frame corresponding to the time interval of each data frame can be extracted from the execution timeline, improving the convenience and efficiency of single-frame time consumption information analysis.
[0069] In this embodiment, after determining the running application unit and its time consumption information within the time interval corresponding to each data frame from the total time consumption information, the method further includes:
[0070] When the running application unit includes multiple units with a hierarchical relationship, the time consumption information of the multiple units is graphically plotted according to the hierarchical relationship of the multiple units from high to low or from low to high, generating a performance analysis chart corresponding to each data frame; the performance analysis chart shows the time consumption area corresponding to each of the multiple units, and the width of the time consumption area corresponding to each unit is adapted to the time consumption information of each unit.
[0071] The performance analysis graph can include a first axis and a second axis. The first axis represents the execution time, and the second axis represents the call stack. Each level is a function. The deeper the call stack, the more levels are involved, and the higher the number of levels. The top is the function currently executing, and the functions below it are its parent functions. The bottom layer of the performance analysis graph is the top-level parent function in the thread, and the top layer is the bottom-level function of each branch function. The width of each function represents its execution time, making it easier for developers to find the widest function, which is the bottleneck function in the current frame.
[0072] Please see Figure 5 It shows the performance analysis graph corresponding to each data frame. The parent function a() has two branches b() and h(), which indicates that a() may have a conditional statement. It can be seen that the processing resources consumed by the b() branch are higher than those of h(). Among them, the top-level function g() takes the longest time.
[0073] In this embodiment, a corresponding performance analysis graph can be drawn based on the running application units running within the time interval corresponding to each data frame and the time consumption information of the running application units. Furthermore, the time consumption information of each unit can be determined based on the width of the time consumption area corresponding to each of the multiple units in the performance analysis graph. This makes it easier for developers to identify the application unit with the longest time consumption within a single frame, improving the efficiency of finding the application unit with the longest time consumption, and thus improving the efficiency of optimizing the application unit with the longest time consumption.
[0074] In this embodiment, the device performance analysis method may further include:
[0075] During the execution of the target application, the process data of the target application is stored in the target stack corresponding to the target application;
[0076] The stack frame pointer pointing to the base address of the target stack is stored in the target register so that, during the process of backtracking the stack information of the target application, the process data in the target stack can be obtained based on the stack frame pointer stored in the target register.
[0077] By modifying the configuration of the performance analysis program, specifically by setting `-fno-omit-frame-pointer`, the stack frame pointer (FP) is retained in a register, preventing other compiler optimization options from optimizing it away. Each process's stack space is one frame; FP points to the bottom of the current process's stack space, while the stack pointer (SP) always points to the top. By tracing back the stack frames, the call process and parameters can be obtained, facilitating the capture of a complete time-consuming call stack. This solves the problem of incomplete function stacks and improves the accuracy and comprehensiveness of stack information acquisition.
[0078] The following uses a game scenario as an example to illustrate the specific implementation process of this application. The performance analysis program can be compiled and configured through an analysis terminal. Figure 6 A schematic diagram of the performance analysis process is shown, which may include:
[0079] 1. Permission collection configuration
[0080] The permission collection configuration adapts the permissions of the performance analysis program to prevent various permission access anomalies. By using `pm list packages -U|grep packageName(game installation package name)`, you can obtain the current game's process data. `process.getInputStream` retrieves the process's output stream, and `line.contains("uid:")` parses the game's UID field from this stream to obtain the specific game UID data. Executing `setuidgid` sets the obtained game UID data as the performance analysis program's UID, ensuring that the performance analysis program and the game share the same UID, preventing various access permission failures.
[0081] 2. Installation package attribute parsing
[0082] The package list parsing is to prevent various debuggable program judgment errors from occurring.
[0083] The installation package's attributes are parsed using `pm dump packageName` (where `packageName` is the game package name). The process output stream is obtained using `process.getInputStream`, and the `debuggable` field of the installation package is parsed using `line.contains("debuggable=true")` to determine if the current game installation package's attributes are debuggable. This avoids the problem of not being able to retrieve debuggable attributes encountered when parsing using `packagelist_parse`.
[0084] 3. Engine compilation configuration
[0085] The engine compilation and configuration will first configure adjustable game attributes to facilitate subsequent performance data processing.
[0086] Setting `android:debuggable` to `true` makes the entire installation package debuggable, facilitating the acquisition of various performance events (perf_event). Adding `-fno-omit-frame-pointer` to the build settings preserves the frame pointer in a register, preventing other build optimizations from optimizing away the stack frame pointer. The frame pointer (FP) is the stack frame pointer. Each process's stack space is one frame, and FP points to the bottom of the current process's stack space. The stack pointer (SP) always points to the top of the stack. By tracing back the stack frames, the code's call process and parameters can be obtained, facilitating the capture of a complete time-consuming call stack and avoiding incomplete stack information issues.
[0087] 4. Data Recording
[0088] Use the command `python app_profiler.py -p com.tencent -r" -e task-clock`
[0089] The command `--call-graph fp --duration 60" -lib.\lib -o perf.data --f 1000` is used to capture performance data for the target game scene. `--call-graph fp` is the default setting. It requires disabling compiler optimizations that affect the stack trace (`-fno-omit-frame-pointer`) to prevent incorrect stack information. Its advantages include low performance overhead, small file size, and fast reporting. `-e task-clock` focuses on capturing data from the `task-clock` event, which represents the actual processor time used by the target task. `-f 1000` uses a sampling frequency of 1000Hz to reduce the performance load on the performance analysis tool. The final result after a period of data collection is the `perf.data` file.
[0090] 5. Single-frame data parsing
[0091] The raw data stores the total time consumption. To see the time consumption data for each frame, it is extracted using eglSwapBuffers as the data interval for each frame. First, subprocess.run is used to call the report command of the performance analysis tool to generate a performance data report and save it to the report.txt file. The generated report file is read and parsed line by line: report_data = file.readlines(); match = pattern.search(line) uses regular expressions to match eglSwapBuffers calls and records the timestamp of each call, saving it to swap_buffers_times. Then, the time interval between each eglSwapBuffers call is calculated: intervals. Based on the final time interval, the performance data for each time interval can be extracted, which helps developers determine the stuttering function information for each frame.
[0092] 6. Comparison with the baseline version
[0093] If there is a historical benchmark version's execution time, a comparison can be made to discover the time difference of the new version. Specifically, the difference in the time ratio between the two versions, the difference in the execution time between the two versions, etc., can be obtained by comparing the performance stacks of the two versions to discover new hot spots.
[0094] 7. Overall information storage
[0095] The device performance analysis method provided in this application is applicable to all models and can extend performance data collection to low-end machines in the overall model range. It can perform statistical analysis on various time-consuming functions on low-end machines according to the characteristics of low-end machines, making it easier to discover high-time-consuming functions in low-end machines. It avoids the overall redundant process caused by various optimization attempts and greatly improves the experience optimization of low-end machines.
[0096] This embodiment also provides a device for analyzing equipment performance; please refer to [link / reference]. Figure 7 The device may include:
[0097] The application information acquisition module 710 is used to acquire target application information of the target application during the operation of the target application on the target device, when the performance analysis program does not have performance data access permissions; the performance analysis program is a program independent of the target application and used for performance data collection; the performance data access permissions are the permissions of the target device to access the performance data of the target device from the system of the target device during the operation of the target application on the target device.
[0098] The permission configuration module 720 is used to configure the permissions of the performance analysis program based on the target application information to obtain the configured performance analysis program; the configured performance analysis program can access the performance data in the system of the target device as the identity of the target application.
[0099] The data acquisition module 730 is used to acquire data during the operation of the target application based on the configured performance analysis program, and obtain the performance data of the target device.
[0100] Furthermore, the application information acquisition module is used for:
[0101] Obtain the installation package identifier corresponding to the target application;
[0102] The process data of the target application is obtained based on the installation package identifier;
[0103] Obtain the target application information from the process data.
[0104] Furthermore, the target application information is the program identifier of the target application;
[0105] The permission configuration module is used for:
[0106] The performance analysis program is configured with permissions based on the program identifier of the target application to obtain a configured performance analysis program; the configured performance analysis program has the program identifier of the target application.
[0107] Furthermore, the target application includes at least one target application unit, and the performance data of the target device includes the total time consumed by the target device in each target application unit during the operation of the target application;
[0108] The device further includes:
[0109] The calling module is used to obtain the call timestamp of each call to the graphics rendering function during the operation of the target application; the graphics rendering function is called once for each data frame rendered;
[0110] The time interval determination module is used to determine the time interval corresponding to each data frame based on the call timestamp of each call to the graphics rendering function; the time interval corresponding to each data frame is determined based on the call timestamp of each data frame and the call timestamp of the next data frame.
[0111] A single-frame analysis module is used to determine, from the total time consumption information, the running application unit running within the time interval corresponding to each data frame and the time consumption information of the running application unit; the running application unit is at least one of the target application units.
[0112] Furthermore, the total time consumption information includes the time consumption information of the at least one target application unit on the runtime timeline; the runtime timeline corresponds to the running process of the target application.
[0113] The single-frame analysis module is used for:
[0114] Based on the call timestamp corresponding to each data frame and the call timestamp corresponding to the next data frame, a target interval corresponding to the time interval of each data frame is determined on the running time axis;
[0115] The running application units running within the target interval on the running time axis and the time consumption information of the running application units are determined as the running application units running within the time interval corresponding to each data frame and the time consumption information of the running application units.
[0116] Furthermore, the device also includes:
[0117] The analysis graph drawing module is used to draw the time consumption information of the multiple units in a hierarchical order, from high to low or from low to high, when the running application unit includes multiple units with a hierarchical relationship, and generate a performance analysis graph corresponding to each data frame; the performance analysis graph shows the time consumption area corresponding to each of the multiple units, and the width of the time consumption area corresponding to each unit is adapted to the time consumption information of each unit.
[0118] Furthermore, the device also includes a stack frame pointer processing module, used for:
[0119] During the execution of the target application, the process data of the target application is stored in the target stack corresponding to the target application;
[0120] The stack frame pointer pointing to the base address of the target stack is stored in the target register so that, during the process of backtracking the stack information of the target application, the process data in the target stack can be obtained based on the stack frame pointer stored in the target register.
[0121] The apparatus provided in the above embodiments can execute the methods provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the above embodiments can be found in the methods provided in any embodiment of this application.
[0122] This embodiment also provides a computer-readable storage medium storing at least one instruction or at least one program, which is loaded by a processor and executed as any of the methods described above in this embodiment.
[0123] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the methods described above.
[0124] Figure 8 This is a block diagram illustrating an electronic device for performance analysis of a device according to an exemplary embodiment. The electronic device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown, the device may include an RF (Radio Frequency) circuit 810, a memory 820 including one or more computer-readable storage media, an input unit 830, a display unit 840, a sensor 850, an audio circuit 860, a WiFi (Wireless Fidelity) module 870, a processor 880 including one or more processing cores, and a power supply 890, among other components. Those skilled in the art will understand that... Figure 8 The terminal structure shown does not constitute a limitation on the terminal and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0125] The RF circuit 810 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and hands it over to one or more processors 880 for processing; additionally, it transmits uplink data to the base station. Typically, the RF circuit 810 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, etc. Furthermore, the RF circuit 810 can also communicate wirelessly with networks and other terminals. Wireless communication can use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communication), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), etc.
[0126] The memory 820 can be used to store software programs and modules. The processor 880 executes various functional applications and data processing by running the software programs and modules stored in the memory 820. The memory 820 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for the functions, etc.; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 820 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 820 may also include a memory controller to provide access to the memory 820 for the processor 880 and the input unit 830.
[0127] The input unit 830 can be used to receive input digital or character information, and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control. Specifically, the input unit 830 may include a touch-sensitive surface 831 and other input devices 832. The touch-sensitive surface 831, also known as a touch display screen or touchpad, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch-sensitive surface 831), and drive the corresponding connection device according to a pre-set program. Optionally, the touch-sensitive surface 831 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, sends it to the processor 880, and can receive and execute commands sent by the processor 880. In addition, the touch-sensitive surface 831 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch-sensitive surface 831, the input unit 830 may also include other input devices 832. Specifically, other input devices 832 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0128] The display unit 840 can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the terminal. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. The display unit 840 may include a display panel 841, which may optionally be configured as an LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), or similar display panel 841. Further, a touch-sensitive surface 831 may cover the display panel 841. When the touch-sensitive surface 831 detects a touch operation on or near it, it transmits the information to the processor 880 to determine the type of touch event. Subsequently, the processor 880 provides corresponding visual output on the display panel 841 according to the type of touch event. The touch-sensitive surface 831 and the display panel 841 can be two independent components to implement input and output functions. However, in some embodiments, the touch-sensitive surface 831 and the display panel 841 can be integrated to achieve input and output functions.
[0129] The terminal may also include at least one sensor 850, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 841 according to the ambient light level, and the proximity sensor can turn off the display panel 841 and / or the backlight when the terminal is moved to the ear. As a type of motion sensor, a gravity acceleration sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity and can be used for applications that identify the terminal's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition-related functions (such as pedometer, tapping), etc. Other sensors that may be configured on the terminal, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.
[0130] Audio circuitry 860, speaker 861, and microphone 862 provide an audio interface between the user and the terminal. Audio circuitry 860 converts received audio data into electrical signals, which are then transmitted to speaker 861, where they are converted into sound signals for output. Conversely, microphone 862 collects sound signals, converts them into electrical signals, which are then received by audio circuitry 860, converted back into audio data, processed by processor 880, and transmitted via RF circuitry 810 to, for example, another terminal, or output to memory 820 for further processing. Audio circuitry 860 may also include an earphone jack to facilitate communication between a peripheral headset and the terminal.
[0131] WiFi is a short-range wireless transmission technology. This terminal, through the WiFi module 870, can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 8 WiFi module 870 is shown, but it is understood that it is not a necessary component of the terminal and can be omitted as needed without changing the nature of the invention.
[0132] The processor 880 is the control center of the terminal, connecting various parts of the terminal through various interfaces and lines. It executes software programs and / or modules stored in the memory 820, and calls data stored in the memory 820 to perform various functions and process data, thereby enabling overall monitoring of the terminal. Optionally, the processor 880 may include one or more processing cores; preferably, the processor 880 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 880.
[0133] The terminal also includes a power supply 890 (such as a battery) to power various components. Preferably, the power supply can be logically connected to the processor 880 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 890 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0134] Although not shown, the terminal may also include a camera, Bluetooth module, etc., which will not be described in detail here. Specifically, in this embodiment, the display unit of the terminal is a touch screen display, and the terminal also includes a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors of the instructions in the method embodiment of the present invention.
[0135] This specification provides the operational steps of the methods described in the embodiments or flowcharts, but more or fewer operational steps may be included based on conventional or non-inventive labor. The steps and order listed in the embodiments are merely one possible execution order among many steps and do not represent the only execution order. In actual system or interrupt product execution, the methods shown in the embodiments or drawings can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment).
[0136] The structure shown in this embodiment is only a partial structure related to the solution of this application and does not constitute a limitation on the device to which the solution of this application is applied. Specific devices may include more or fewer components than shown, or combinations of certain components, or arrangements of different components. It should be understood that the methods, apparatuses, etc., disclosed in this embodiment can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of modules 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 between devices or unit modules through some interfaces.
[0137] Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0138] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0139] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for analyzing the performance of a device, characterized in that, include: During the execution of the target application on the target device, when the performance analysis program does not have access to performance data, the target application information of the target application is obtained; The performance analysis program is a program independent of the target application and used for performance data collection; the performance data access permission is the permission to access the performance data of the target device from the system of the target device during the running of the target application. Based on the target application information, the performance analysis program is configured with permissions to obtain the configured performance analysis program. The configured performance analysis program can access the performance data in the target device's system as the target application. Based on the configured performance analysis program, data is collected during the operation of the target application to obtain the performance data of the target device.
2. The method according to claim 1, characterized in that, The step of obtaining the target application information corresponding to the target application includes: Obtain the installation package identifier corresponding to the target application; The process data of the target application is obtained based on the installation package identifier; Obtain the target application information from the process data.
3. The method according to claim 1 or 2, characterized in that, The target application information is the program identifier of the target application; The step of configuring permissions for the performance analysis program based on the target application information to obtain the configured performance analysis program includes: The performance analysis program is configured with permissions based on the program identifier of the target application to obtain a configured performance analysis program; the configured performance analysis program has the program identifier of the target application.
4. The method according to claim 1, characterized in that, The target application includes at least one target application unit, and the performance data of the target device includes the total time consumed by the target device in each target application unit during the operation of the target application. The method further includes: During the execution of the target application, the call timestamp of each call to the graphics rendering function is obtained; the graphics rendering function is called once for each data frame rendered. The time interval corresponding to each data frame is determined based on the call timestamp of each call to the graphics rendering function; the time interval corresponding to each data frame is determined based on the call timestamp of each data frame and the call timestamp of the next data frame. The running application unit and the time consumption information of the running application unit are determined from the total time consumption information within the time interval corresponding to each data frame; the running application unit is at least one of the target application units.
5. The method according to claim 4, characterized in that, The total time consumption information includes the time consumption information of the at least one target application unit on the runtime timeline; the runtime timeline corresponds to the running process of the target application. Determining the running application unit and its time consumption information within the time interval corresponding to each data frame from the total time consumption information includes: Based on the call timestamp corresponding to each data frame and the call timestamp corresponding to the next data frame, a target interval corresponding to the time interval of each data frame is determined on the running time axis; The running application units running within the target interval on the running time axis and the time consumption information of the running application units are determined as the running application units running within the time interval corresponding to each data frame and the time consumption information of the running application units.
6. The method according to claim 4 or 5, characterized in that, After determining the running application unit and its time consumption information within the time interval corresponding to each data frame from the total time consumption information, the method further includes: When the running application unit includes multiple units with a hierarchical relationship, the time consumption information of the multiple units is graphically plotted according to the hierarchical relationship of the multiple units from high to low or from low to high, generating a performance analysis chart corresponding to each data frame; the performance analysis chart shows the time consumption area corresponding to each of the multiple units, and the width of the time consumption area corresponding to each unit is adapted to the time consumption information of each unit.
7. The method according to claim 1, characterized in that, The method further includes: During the execution of the target application, the process data of the target application is stored in the target stack corresponding to the target application; The stack frame pointer pointing to the base address of the target stack is stored in the target register so that, during the process of backtracking the stack information of the target application, the process data in the target stack can be obtained based on the stack frame pointer stored in the target register.
8. A performance analysis device for equipment, characterized in that, include: The application information acquisition module is used to acquire the target application information of the target application during the operation of the target application on the target device, when the performance analysis program does not have access to performance data. The performance analysis program is a program independent of the target application and used for performance data collection; the performance data access permission is the permission to access the performance data of the target device from the system of the target device during the running of the target application. The permission configuration module is used to configure the permissions of the performance analysis program based on the target application information, so as to obtain the configured performance analysis program. The configured performance analysis program can access the performance data in the target device's system as the target application. The data acquisition module is used to collect data during the operation of the target application based on the configured performance analysis program, and obtain the performance data of the target device.
9. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the performance analysis method of the device as described in any one of claims 1 to 7.
10. A computer storage medium, characterized in that, The storage medium stores at least one instruction or at least one program, which is loaded and executed by a processor using the performance analysis method of the device as described in any one of claims 1 to 7.