Application program operation method, device, equipment and storage medium
By obtaining the number of clock pulses, network performance indicators and main thread operation parameters of the mobile terminal, and determining the target loading resources, it solves the problem of large differences in application operation effects under different hardware conditions and network environments, and improves the operation speed and performance of the application .
Patent Information
- Application Number
- CN202111539712.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-15
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-12-15
AI Technical Summary
There are large differences in the operation effects of application programs in mobile devices under different hardware conditions or network environments, and the existing technology is difficult to flexibly solve performance and network problems, resulting in inconsistent operation effects.
By obtaining the clock pulse count information of the mobile terminal, calculating the central processor occupancy rate; collecting network performance indicators, calculating network performance index; monitoring the main thread running cycle parameters, calculating the running fluency; determining the target loading resources based on these indicators, and adjusting the application runs to suit the hardware and network environment.
It realizes flexible adaptation of applications under different hardware conditions and network environments, improves operating speed and performance, and reduces operating problems caused by hardware or network differences.
Smart Images

Figure CN114201304B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of resource allocation, and in particular to a method, device, equipment and storage medium for running an application. Background Art
[0002] With the development of mobile Internet technology, mobile device manufacturers are constantly innovating, making various mobile devices with different hardware configurations running on the Internet. The hardware gap between devices is also getting bigger and bigger, resulting in large differences in the running effects of applications on devices with different hardware conditions, and even the problem of old devices being unable to run.
[0003] In the prior art, in order to make the application run normally on devices with different hardware conditions, the hardware parameters of the mobile device, such as the device model, kernel version, and processor type, are generally obtained before the application is installed. Then, the software package that will eventually run on the device is downloaded based on the obtained hardware parameters, and a backward compatible software package is installed for devices with lower versions, thereby taking into account the software running effects of different devices. However, the compatible software package set by hardware parameters can only solve the running problems on hardware devices with large differences, and cannot flexibly solve the performance problems or network problems that occur during the software running process, resulting in large differences in the running effects of applications in mobile devices with different hardware conditions or network environments. Summary of the invention
[0004] The present invention provides an application program running method, device, equipment and storage medium, which are used to solve the technical problem that the running effects of application programs vary greatly in mobile devices with different hardware conditions or network environments.
[0005] A first aspect of the present invention provides a method for running an application, comprising:
[0006] Acquiring clock pulse quantity information of the mobile terminal, and calculating the CPU occupancy rate of the mobile terminal according to the clock pulse quantity information;
[0007] Obtaining available physical memory information by calculating the memory occupied by the application running on the mobile terminal;
[0008] Collecting network performance indicators of the mobile terminal, and calculating a network performance index of the mobile terminal according to the network performance indicators;
[0009] Calculating the running loop parameters of the main thread of the mobile terminal to obtain the running smoothness;
[0010] According to the CPU occupancy rate, the available physical memory information, the network performance index and the running fluency, the target loading resources of the target application are determined, and the target application is run according to the target loading resources.
[0011] Optionally, in a first implementation manner of the first aspect of the present invention, the acquiring clock pulse quantity information of the mobile terminal, and calculating the CPU occupancy rate of the mobile terminal according to the clock pulse quantity information, includes:
[0012] By using a preset host statistical function, the central processing unit load information of the mobile terminal is counted to obtain the central processing unit load data;
[0013] Extracting clock pulse quantity information from the CPU load data, the clock pulse quantity information including a first clock pulse quantity in a user process mode, a second clock pulse quantity in a kernel process mode, a third clock pulse quantity in an idle mode, and a fourth clock pulse quantity in a wait mode;
[0014] The CPU occupancy rate of the mobile terminal is calculated according to the first clock pulse number, the second clock pulse number, the third clock pulse number and the fourth clock pulse number.
[0015] Optionally, in a second implementation of the first aspect of the present invention, obtaining the available physical memory information by calculating the memory occupied by the application running on the mobile terminal includes:
[0016] Reading firmware parameter information of the mobile terminal, and extracting inherent physical memory information in the firmware parameter information;
[0017] Obtaining the number of application program threads and the number of kernel threads in active state through a preset host statistical function, and calculating the occupied physical memory information of the mobile terminal according to the number of application program threads and the number of kernel threads;
[0018] The available physical memory information of the mobile terminal is calculated according to the inherent physical memory information and the occupied physical memory information.
[0019] Optionally, in a third implementation manner of the first aspect of the present invention, collecting the network performance indicator of the mobile terminal and calculating the network performance index of the mobile terminal according to the network performance indicator includes:
[0020] Inject network performance monitoring scripts into target applications through preset hook functions;
[0021] Collecting network performance indicators of the mobile terminal through the network performance monitoring script, wherein the network performance indicators include connection establishment time, uplink traffic and downlink traffic;
[0022] Based on the connection establishment duration, the uplink traffic, and the downlink traffic, a network performance index of the mobile terminal is calculated.
[0023] Optionally, in a fourth implementation manner of the first aspect of the present invention, the calculating of the running loop parameters of the main thread of the mobile terminal to obtain the running fluency includes:
[0024] Create a jam monitoring sub-thread, and monitor the running loop parameters of the main thread through the jam monitoring sub-thread to obtain the entry time of each state domain in the main thread;
[0025] Based on the entry time of each state domain in the main thread, the switching time between any two adjacent state domains in the main thread is calculated to obtain the state domain switching duration;
[0026] The running fluency of the mobile terminal is calculated according to the state domain switching duration.
[0027] Optionally, in a fifth implementation manner of the first aspect of the present invention, determining a target loading resource of a target application according to the CPU occupancy rate, the available physical memory information, the network performance index, and the running fluency, and running the target application according to the target loading resource includes:
[0028] Determine whether the CPU occupancy rate is higher than a preset occupancy rate threshold, determine whether the available physical memory information is lower than a preset memory threshold, determine whether the network performance index is lower than a preset performance index threshold, and determine whether the operation fluency is lower than a preset fluency threshold, to obtain a target judgment result;
[0029] Based on the target determination result, determining a target resource loading level of the target application program;
[0030] The target loading resources of the target application are determined by the target resource loading level, and the target application is run according to the target loading resources.
[0031] Optionally, in a sixth implementation manner of the first aspect of the present invention, determining a target loading resource of the target application program by using the target resource loading level, and running the target application program according to the target loading resource includes:
[0032] Determining whether the target resource loading level is greater than or equal to a preset optimized resource loading level;
[0033] If the target resource loading level is greater than or equal to the preset optimized resource loading level, obtaining optimized resources from the preset loaded resources, and setting the optimized resources as target loaded resources of the target application;
[0034] If the target resource loading level is lower than the preset optimized resource loading level, obtaining the target loading resource according to the target resource loading level;
[0035] The target application is loaded according to the target loading resource.
[0036] A second aspect of the present invention provides a device for running an application, comprising:
[0037] An acquisition module, used to acquire clock pulse quantity information of a mobile terminal, and calculate the CPU occupancy rate of the mobile terminal according to the clock pulse quantity information;
[0038] A calculation module, used to obtain available physical memory information by calculating the memory occupied by the application programs running on the mobile terminal;
[0039] A collection module, used to collect the network performance indicators of the mobile terminal, and calculate the network performance index of the mobile terminal according to the network performance indicators;
[0040] A loop module, used to calculate the running loop parameters of the main thread of the mobile terminal to obtain the running smoothness;
[0041] The running module is used to determine the target loading resources of the target application according to the CPU occupancy rate, the available physical memory information, the network performance index and the running fluency, and run the target application according to the target loading resources.
[0042] Optionally, in a first implementation of the second aspect of the present invention, the acquisition module is specifically used to:
[0043] By using a preset host statistical function, the central processing unit load information of the mobile terminal is counted to obtain the central processing unit load data;
[0044] Extracting clock pulse quantity information from the CPU load data, the clock pulse quantity information including a first clock pulse quantity in a user process mode, a second clock pulse quantity in a kernel process mode, a third clock pulse quantity in an idle mode, and a fourth clock pulse quantity in a wait mode;
[0045] The CPU occupancy rate of the mobile terminal is calculated according to the first clock pulse number, the second clock pulse number, the third clock pulse number and the fourth clock pulse number.
[0046] Optionally, in a second implementation of the second aspect of the present invention, the calculation module is specifically used to:
[0047] Reading firmware parameter information of the mobile terminal, and extracting inherent physical memory information in the firmware parameter information;
[0048] Obtaining the number of application program threads and the number of kernel threads in active state through a preset host statistical function, and calculating the occupied physical memory information of the mobile terminal according to the number of application program threads and the number of kernel threads;
[0049] The available physical memory information of the mobile terminal is calculated according to the inherent physical memory information and the occupied physical memory information.
[0050] Optionally, in a third implementation of the second aspect of the present invention, the acquisition module is specifically used to:
[0051] Inject network performance monitoring scripts into target applications through preset hook functions;
[0052] Collecting network performance indicators of the mobile terminal through the network performance monitoring script, wherein the network performance indicators include connection establishment time, uplink traffic and downlink traffic;
[0053] Based on the connection establishment duration, the uplink traffic, and the downlink traffic, a network performance index of the mobile terminal is calculated.
[0054] Optionally, in a fourth implementation of the second aspect of the present invention, the circulation module is specifically used for:
[0055] Create a jam monitoring sub-thread, and monitor the running loop parameters of the main thread through the jam monitoring sub-thread to obtain the entry time of each state domain in the main thread;
[0056] Based on the entry time of each state domain in the main thread, the switching time between any two adjacent state domains in the main thread is calculated to obtain the state domain switching duration;
[0057] The running fluency of the mobile terminal is calculated according to the state domain switching duration.
[0058] Optionally, in a fifth implementation of the second aspect of the present invention, the operation module includes:
[0059] A judgment unit, used to judge whether the CPU occupancy rate is higher than a preset occupancy rate threshold, whether the available physical memory information is lower than a preset memory threshold, whether the network performance index is lower than a preset performance index threshold, and whether the operation fluency is lower than a preset fluency threshold, to obtain a target judgment result;
[0060] a determination unit, configured to determine a target resource loading level of a target application based on the target determination result;
[0061] The running unit is used to determine the target loading resource of the target application according to the target resource loading level, and run the target application according to the target loading resource.
[0062] Optionally, in a sixth implementation of the second aspect of the present invention, the operating unit is specifically configured to:
[0063] Determining whether the target resource loading level is greater than or equal to a preset optimized resource loading level;
[0064] If the target resource loading level is greater than or equal to the preset optimized resource loading level, obtaining optimized resources from the preset loaded resources, and setting the optimized resources as target loaded resources of the target application;
[0065] If the target resource loading level is lower than the preset optimized resource loading level, obtaining the target loading resource according to the target resource loading level;
[0066] The target application is loaded according to the target loading resource.
[0067] The third aspect of the present invention provides an application running device, comprising: a memory and at least one processor, wherein the memory stores a computer program; the at least one processor calls the computer program in the memory so that the application running device executes the above-mentioned application running method.
[0068] A fourth aspect of the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes the above-mentioned method for running the application program.
[0069] In the technical solution provided by the present invention, the clock pulse number information of the mobile terminal is obtained, and the central processing unit occupancy rate of the mobile terminal is calculated according to the clock pulse number information; the available physical memory information is obtained by calculating the memory occupied by the application running on the mobile terminal; the network performance indicators of the mobile terminal are collected, and the network performance index of the mobile terminal is calculated according to the network performance indicators; the running loop parameters of the main thread of the mobile terminal are calculated to obtain the running smoothness; the target loading resources of the target application are determined according to the central processing unit occupancy rate, the available physical memory information, the network performance index and the running smoothness, and the target application is run according to the target loading resources. In an embodiment of the present invention, the CPU occupancy rate is calculated by the number of clock pulses of the mobile terminal, and the CPU occupancy rate is used to measure the CPU computing power of the mobile terminal. Then, the available physical memory information of the mobile terminal is calculated by the memory size occupied by the running application, and the available physical memory information is used to measure the temporary data storage capacity of the mobile terminal. Then, the network performance index of the mobile terminal is calculated by the network performance index, and the network performance index is used to measure the network carrying capacity of the mobile terminal. Then, the running smoothness of the mobile terminal is calculated by the running loop parameters of the main thread, and the running smoothness is used to measure the screen rendering ability of the mobile terminal. Finally, the target loading resources of the target application are determined by combining the CPU occupancy rate, the available physical memory information, the network performance index and the running smoothness. The present invention can solve the technical problem that the running effects of applications vary greatly in mobile devices with different hardware conditions or network environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 A schematic diagram of an embodiment of a method for running an application program in an embodiment of the present invention;
[0071] Figure 2 A schematic diagram of another embodiment of a method for running an application program in an embodiment of the present invention;
[0072] Figure 3 A schematic diagram of an embodiment of a device for running an application program in an embodiment of the present invention;
[0073] Figure 4 It is a schematic diagram of another embodiment of a device for running an application program in an embodiment of the present invention;
[0074] Figure 5 The figure is a schematic diagram of an embodiment of a device for running an application program in an embodiment of the present invention. DETAILED DESCRIPTION
[0075] The embodiments of the present invention provide a method, apparatus, device and storage medium for running an application program, which are used to solve the technical problem that the running effects of the application program vary greatly in mobile devices with different hardware conditions or network environments.
[0076] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0077] It is understandable that the execution subject of the present invention can be a running device of an application, or a mobile terminal or a server, which is not limited here. The embodiment of the present invention is described by taking a mobile terminal as an example of the execution subject. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0078] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the method for running an application in an embodiment of the present invention includes:
[0079] 101. Obtain clock pulse quantity information of the mobile terminal, and calculate the CPU occupancy rate of the mobile terminal according to the clock pulse quantity information;
[0080] It should be noted that the central processing unit (CPU) occupancy rate refers to the utilization rate of CPU resources by applications running on a mobile terminal. CPU resources are important computing resources for mobile devices. If the CPU is continuously in a high-load state, on the one hand, it will cause system freezes, and on the other hand, it will cause the mobile device to heat up and consume power quickly, affecting the device life and user experience. Therefore, in order to reduce the CPU occupancy rate of applications on mobile terminals and increase the running speed of applications, the server calculates the CPU occupancy rate through the number of clock pulses of the mobile terminal to determine the loading resources of the application through the CPU occupancy rate.
[0081] It should be noted that the number of clock pulses refers to the operating frequency of the CPU during operation (the number of synchronous clock pulses occurring within 1 second), which is a pulse signal continuously emitted at a certain voltage amplitude and a certain time interval, that is, the CPU clock frequency, referred to as CPU frequency, in Hz, CPU frequency. In one embodiment, the mobile terminal obtains the clock pulse quantity information of the mobile terminal through a preset host statistical function, wherein the host statistical function is an interface function provided by the mobile terminal operating system, which is used to obtain the hardware resource data of the mobile terminal.
[0082] In one embodiment, since threads are the basic units for deploying and allocating resources by the mobile terminal operating system, and when an application runs as a process, it is equivalent to multiple different threads running. Therefore, the mobile terminal reads the number of occupied threads of the running application, calculates the ratio of the number of occupied threads to the total number of threads, and obtains the CPU occupancy rate. This embodiment can accurately calculate the CPU occupancy rate, thereby improving the accuracy of application loading resource selection.
[0083] 102. Obtain available physical memory information by calculating the memory occupied by the application running on the mobile terminal;
[0084] It should be noted that physical memory (random access memory, RAM) refers to random access memory, which is the internal memory for direct data exchange between the mobile terminal operating system and the CPU. It can be read and written at any time and at a very high speed. It is usually used as a temporary data storage medium for the operating system or other running applications. Physical memory, like CPU, is a scarce resource in the mobile terminal operating system and is also the resource most likely to generate competition. Therefore, in order to improve the running efficiency of the application, the mobile terminal calculates the available physical memory information of the mobile terminal through the memory size occupied by the running application. The available physical memory information is used to indicate the available physical memory size of the mobile terminal. This embodiment calculates the available physical memory information of the mobile terminal to determine the target resources to be loaded by the target application, thereby improving the running speed and performance of the application by selectively loading resources.
[0085] In one embodiment, the mobile terminal reads the inherent physical memory information of the mobile terminal through a preset host statistical function, and reads the physical memory size occupied by the application running in the mobile terminal through a preset application running information reading interface to obtain the occupied physical memory information, and then subtracts the occupied physical memory information from the inherent physical memory information to obtain the available physical memory information of the mobile terminal. This embodiment can quickly calculate the available physical memory information of the mobile terminal, thereby improving the efficiency of the application selecting loading resources, and further improving the running speed and performance of the application.
[0086] 103. Collect network performance indicators of the mobile terminal, and calculate a network performance index of the mobile terminal according to the network performance indicators;
[0087] It should be noted that due to the complex network environment of mobile terminals, the network of mobile terminals may switch between different network types such as 5G / 4G / 3G / 2.5G / 2G / WIFI. In addition, traditional operator networks also have problems such as slow domain name resolution (DNS), high failure rate, DNS hijacking, domestic operator network interconnection, low domestic bandwidth and slow transmission for overseas access, etc. Network problems will cause the mobile terminal application to fail to run normally. Therefore, evaluating and analyzing the network performance of the mobile terminal and selecting the resources to be loaded by the application according to the current network performance index can reduce the occurrence of application failures and ensure that the application can adapt to different network environments, so that the application's running performance is improved and the failure rate is reduced, thereby improving the overall running performance of the application.
[0088] It should be noted that network performance indicators include, but are not limited to, transmission control protocol (TCP) connection establishment time, DNS time, secure sockets layer (SSL) time, first packet time, response time, hypertext transfer protocol (HTTP) error rate, network error rate, traffic, and other parameters used to measure network performance. In one embodiment, the mobile terminal collects network performance indicators of the mobile terminal through a preset embedding code, and classifies the network performance of the mobile terminal through the collected network performance indicators to obtain a network performance index of the mobile terminal. This embodiment can quickly obtain network performance indicators under the current network environment, thereby quickly determining application loading resources suitable for the current network environment, thereby improving the running speed and performance of the application.
[0089] 104. Calculate the running loop parameters of the main thread of the mobile terminal to obtain the running smoothness;
[0090] It should be noted that the display of graphics on the screen of the mobile terminal is actually the result of the collaborative work of the graphics processing unit (GPU), the CPU and the display. The CPU is responsible for calculating the display content, including view creation, layout calculation, image decoding, text drawing, etc. After the CPU completes the calculation, it will submit the calculation content to the GPU. The GPU will transform, synthesize, and render, and then submit the rendering results to the frame buffer. When the next vertical synchronization signal (V-Sync) arrives, it will be displayed on the display. If the CPU and GPU miss the arrival of the next V-Sync (usually 16.67ms) in order to complete their own tasks before the image is actually displayed on the screen, the display screen will still be the content of the previous frame, causing the interface to freeze. In order to reduce the interface freeze and improve the running performance of the application, the mobile terminal increases the running loop parameters (RunLoop) of the main scene of the mobile terminal to determine the running flow degree of the mobile terminal, so as to select the application loading resources suitable for the current running flow degree through the running smoothness, thereby improving the running speed and performance of the application.
[0091] In one embodiment, the number of frames per second (FPS) is a measure of the amount of information used to save and display dynamic videos. The higher the number of frames per second, the smoother the displayed picture will be. Therefore, the mobile terminal collects the number of frames transmitted within a preset time (such as 2 seconds) of the mobile terminal, calculates the frame loss rate of the mobile terminal, and rates the running smoothness of the mobile terminal by the frame loss rate to obtain the running smoothness of the mobile terminal. This embodiment can accurately determine the running smoothness of the mobile terminal, so as to determine the application loading resources suitable for the current picture rendering performance through the running smoothness, thereby improving the running speed and performance of the application.
[0092] 105. Determine the target loading resources of the target application according to the CPU occupancy rate, available physical memory information, network performance index and running smoothness, and run the target application according to the target loading resources.
[0093] It should be noted that the real hardware device environment and network environment of the mobile terminal can be accurately measured through the CPU occupancy rate, available physical memory information, network performance index and running smoothness, so as to accurately select the target loading resources that are suitable for the current hardware device environment and network environment. For example, when the hardware device environment and network environment are poor, target loading resources with low requirements for hardware device performance and network performance are selected, such as resources with high image compression rate or shielding entrances of high-consumption functions, and when the hardware device environment and network environment are good, target loading resources with high requirements for hardware device performance and network performance are selected, such as resources with low image compression rate or providing entrances of high-consumption functions. This implementation method can ensure the normal operation of the application program by downgrading or upgrading the loading resources under different hardware device environments and different network environments, making the operation mode of the application program more flexible.
[0094] In one embodiment, the mobile terminal grades the operating environment of the mobile terminal according to the weight coefficients corresponding to the central processing unit occupancy rate, available physical memory information, network performance index and operating fluency, and determines the target loading resources of the target application according to the classification results, so that the mobile terminal runs the target application according to the target loading resources.
[0095] Furthermore, the server stores the target loaded resources in the blockchain database, which is not specifically limited here.
[0096] In an embodiment of the present invention, the CPU occupancy rate is calculated by the number of clock pulses of the mobile terminal, and the CPU occupancy rate is used to measure the CPU computing power of the mobile terminal. Then, the available physical memory information of the mobile terminal is calculated by the memory size occupied by the running application, and the available physical memory information is used to measure the temporary data storage capacity of the mobile terminal. Then, the network performance index of the mobile terminal is calculated by the network performance index, and the network performance index is used to measure the network carrying capacity of the mobile terminal. Then, the running smoothness of the mobile terminal is calculated by the running loop parameters of the main thread, and the running smoothness is used to measure the screen rendering ability of the mobile terminal. Finally, the target loading resources of the target application are determined by combining the CPU occupancy rate, the available physical memory information, the network performance index and the running smoothness. The present invention can solve the technical problem that the running effects of applications vary greatly in mobile devices with different hardware conditions or network environments.
[0097] See also Figure 2 Another embodiment of the method for running an application in the embodiment of the present invention includes:
[0098] 201. Obtain clock pulse quantity information of the mobile terminal, and calculate the CPU occupancy rate of the mobile terminal according to the clock pulse quantity information;
[0099] Specifically, the server collects statistics on the CPU load information of the mobile terminal through a preset host statistical function to obtain CPU load data; the server extracts clock pulse number information from the CPU load data, and the clock pulse number information includes a first clock pulse number in user process mode, a second clock pulse number in kernel process mode, a third clock pulse number in idle mode, and a fourth clock pulse number in wait mode; the server calculates the CPU occupancy rate of the mobile terminal based on the first clock pulse number, the second clock pulse number, the third clock pulse number, and the fourth clock pulse number.
[0100] It should be noted that the preset host statistics function is an interface function provided by the mobile terminal operating system, which is used to obtain the hardware resource data of the mobile terminal, such as the host_statistics function of the iOS operating system. The mobile terminal collects and counts the CPU load information of the mobile terminal through the preset host statistics function to obtain the CPU load data, where the CPU load data includes the number of clock pulses in various process modes. The various process modes include user process mode, kernel process mode, idle mode and wait mode. For example, remote server access, database operations, etc. belong to operations in the user process mode, and creating child processes, allocating memory, IO, etc. belong to operations in the kernel process mode. When the CPU initiates a read and write operation, it is in wait mode while waiting for the disk drive to read data into the memory. When the CPU has no computing tasks, it is in idle mode. There is no specific limitation.
[0101] In one implementation, the mobile terminal adds the first clock pulse number, the second clock pulse number, the third clock pulse number and the fourth clock pulse number to obtain the total clock pulse number, and then divides the sum of the first clock pulse number and the first clock pulse number by the total clock pulse number to obtain the process pulse occupancy rate, and sets the process pulse occupancy rate as the central processing unit occupancy rate of the mobile terminal. This implementation can accurately calculate the CPU occupancy rate based on the operating principle of the CPU, thereby accurately selecting the loading resources of the application, thereby improving the running speed and performance of the application under different hardware conditions.
[0102] 202. Obtain available physical memory information by calculating the memory occupied by the application running on the mobile terminal;
[0103] Specifically, the server reads the firmware parameter information of the mobile terminal and extracts the inherent physical memory information in the firmware parameter information; the server obtains the number of active application threads and the number of kernel threads through a preset host statistical function, and calculates the occupied physical memory information of the mobile terminal based on the number of application threads and the number of kernel threads; the server calculates the available physical memory information of the mobile terminal based on the inherent physical memory information and the occupied physical memory information.
[0104] In one embodiment, the mobile terminal reads the firmware parameter information of the mobile terminal through a preset host statistical function, wherein the firmware parameter information is used to indicate the firmware parameters of the mobile terminal, such as the device model, device name, physical memory size, and system version, etc. The mobile terminal extracts the inherent physical memory information in the firmware parameter information, and the inherent physical memory information is used to indicate the physical memory size of the mobile device memory firmware. In order to accurately calculate the available physical memory information of the mobile terminal, the mobile terminal reads the number of application threads and the number of kernel threads in the running state through a preset host statistical function, and calculates the size of the physical memory occupied by the number of application threads and the number of kernel threads in the running state, obtains the occupied physical memory information, and then subtracts the occupied physical memory information from the inherent physical memory information to obtain the available physical memory information of the mobile terminal.
[0105] 203. Collecting network performance indicators of the mobile terminal, and calculating a network performance index of the mobile terminal according to the network performance indicators;
[0106] Specifically, the server injects a network performance monitoring script into the target application through a preset hook function; the server collects network performance indicators of the mobile terminal through the network performance monitoring script, and the network performance indicators include connection establishment time, uplink traffic and downlink traffic; the server calculates the network performance index of the mobile terminal based on the connection establishment time, uplink traffic and downlink traffic.
[0107] In this embodiment, in order to accurately obtain the real network environment parameters of the mobile terminal, the mobile terminal injects a preset network performance monitoring script into a preset hook function of the target application, wherein the preset hook function is used to indicate the life cycle function of the underlying network library, and the network performance monitoring script can be executed at different life cycles of the underlying network library, so that the network performance monitoring script can monitor the real network environment of the mobile terminal without invading the business code of the target application, thereby improving the network monitoring performance. In this embodiment, the network performance indicators of the mobile terminal are collected through the network performance monitoring script, wherein the network performance indicators include the connection (TCP) establishment time, the uplink traffic and the downlink traffic, and the mobile terminal classifies the network performance of the mobile terminal by calculating the ratio of the network performance indicators to the benchmark performance indicators, and obtains the network performance index.
[0108] 204. Create a jam monitoring sub-thread, and monitor the running loop parameters of the main thread through the jam monitoring sub-thread to obtain the entry time of each state domain in the main thread;
[0109] In this implementation, in order to calculate the running smoothness of the mobile terminal, the mobile terminal creates a jam monitoring sub-thread to monitor the run loop parameters (RunLoop) of the main thread, where the run loop parameters are used to indicate the switching time of different state domains in the main thread. The mobile terminal extracts the entry time of each state domain in the main thread from the run loop parameters for subsequent running smoothness calculations.
[0110] 205. Based on the entry time of each state domain in the main thread, the switching time between any two adjacent state domains in the main thread is calculated to obtain the state domain switching duration;
[0111] In this implementation, the mobile terminal calculates the switching duration between any two adjacent state domains in real time based on the entry time of each state domain in the main thread, and obtains the state domain switching duration, such as the state domain before the signal is sent and the state domain after the signal is sent. This implementation can accurately calculate the state domain switching duration, and then accurately calculate the running smoothness of the mobile terminal.
[0112] 206. Calculate the running fluency of the mobile terminal according to the state domain switching duration;
[0113] In one implementation, the mobile terminal calculates the ratio of the state domain switching duration to the reference switching duration, obtains the switching smoothness of the state domain, and sets the switching smoothness of the state domain as the running smoothness of the mobile terminal. This implementation can accurately calculate the running smoothness of the mobile terminal, thereby accurately selecting the loading resources of the application, and thus improving the running speed and performance of the application under different hardware conditions.
[0114] 207. Determine the target loading resources of the target application according to the CPU occupancy rate, available physical memory information, network performance index and running smoothness, and run the target application according to the target loading resources.
[0115] Specifically, determine whether the CPU occupancy rate is higher than a preset occupancy rate threshold, determine whether the available physical memory information is lower than a preset memory threshold, determine whether the network performance index is lower than a preset performance index threshold, and determine whether the running fluency is lower than a preset fluency threshold to obtain a target judgment result;
[0116] Based on the target determination result, determine the target resource loading level of the target application program;
[0117] The target loading resources of the target application are determined through the target resource loading level, and the target application is run according to the target loading resources.
[0118] It should be noted that the mobile terminal determines whether the CPU occupancy rate is higher than the preset occupancy rate threshold to obtain a first judgment result, determines whether the available physical memory information is lower than the preset memory threshold to obtain a second judgment result, determines whether the network performance index is lower than the preset performance index threshold to obtain a third judgment result, and determines whether the running fluency is lower than the preset fluency threshold to obtain a fourth judgment result, and then combines the first judgment result, the second judgment result, the third judgment result and the fourth judgment result to obtain a target judgment result. The mobile terminal determines the target resource loading resource of the target application according to the resource loading weight corresponding to each judgment result in the target judgment result. If the first judgment result is 0, the second judgment result is 1, the third judgment result is 1 and the fourth judgment result is 0, and the resource loading weight corresponding to the first judgment result is 5, the resource loading weight corresponding to the second judgment result is 3, the resource loading weight corresponding to the third judgment result is 2 and the resource loading weight corresponding to the fourth judgment result is 1, then the target resource loading level of the target application is 0*5+1*3+1*2+0*1=5, which is not specifically limited.
[0119] Furthermore, the server determines the target loading resources of the target application through the target resource loading level, and runs the target application according to the target loading resources, including: the server determines whether the target resource loading level is greater than or equal to the preset optimization resource loading level; if the target resource loading level is greater than or equal to the preset optimization resource loading level, the server obtains the optimization resources from the preset loading resources, and sets the optimization resources as the target loading resources of the target application; if the target resource loading level is less than the preset optimization resource loading level, the server obtains the target loading resources according to the target resource loading level; the server loads the target application according to the target loading resources.
[0120] It should be noted that in order to adapt resource loading to mobile terminals with different hardware device conditions and network environment conditions, so that mobile terminals with good hardware device conditions and network environment conditions can experience functions with high performance requirements, and mobile terminals with poor hardware device conditions or network environment conditions can ensure the normal and smooth operation of applications, the mobile terminal determines whether to load optimized resources by judging whether the target resource loading level is greater than or equal to the preset optimized resource loading level, wherein the optimized resources are used to indicate function packages with high requirements for mobile terminal device hardware and network, such as real-time augmented reality (AR) functions. If the target resource loading level is greater than or equal to the preset optimized resource loading level, the optimized resources are set as the target loading resources, and the target application is run through the target loading resources. If the target resource loading level is less than the preset optimized resource loading level, the optimized resources are not loaded, and the target application is run only according to the target loading resources corresponding to the target resource loading level, so as to avoid the situation where the mobile terminal with poor hardware device conditions or network environment conditions is stuck or cannot be used normally.
[0121] In an embodiment of the present invention, the CPU occupancy rate is calculated by the number of clock pulses of the mobile terminal, and the CPU occupancy rate is used to measure the CPU computing power of the mobile terminal. Then, the available physical memory information of the mobile terminal is calculated by the memory size occupied by the running application, and the available physical memory information is used to measure the temporary data storage capacity of the mobile terminal. Then, the network performance index of the mobile terminal is calculated by the network performance index, and the network performance index is used to measure the network carrying capacity of the mobile terminal. Then, the running fluency of the mobile terminal is calculated by the switching time of each state domain in the main thread, and the running fluency is used to measure the screen rendering ability of the mobile terminal. Finally, the target loading resource of the target application is determined by combining the CPU occupancy rate, the available physical memory information, the network performance index and the running fluency. The present invention can solve the technical problem that the running effect of the application is greatly different in mobile devices with different hardware conditions or network environments.
[0122] The above describes the method for running the application in the embodiment of the present invention. The following describes the device for running the application in the embodiment of the present invention. Figure 3 In one embodiment of the present invention, an application program running device includes:
[0123] The acquisition module 301 is used to acquire the clock pulse quantity information of the mobile terminal, and calculate the CPU occupancy rate of the mobile terminal according to the clock pulse quantity information;
[0124] A calculation module 302 is used to obtain available physical memory information by calculating the memory occupied by the application programs running on the mobile terminal;
[0125] The collection module 303 is used to collect the network performance indicators of the mobile terminal and calculate the network performance index of the mobile terminal according to the network performance indicators;
[0126] A loop module 304 is used to calculate the running loop parameters of the main thread of the mobile terminal to obtain the running smoothness;
[0127] The running module 305 is used to determine the target loading resources of the target application according to the CPU occupancy rate, the available physical memory information, the network performance index and the running fluency, and run the target application according to the target loading resources.
[0128] Furthermore, the target loaded resources are stored in the blockchain database, which is not specifically limited here.
[0129] In an embodiment of the present invention, the CPU occupancy rate is calculated by the number of clock pulses of the mobile terminal, and the CPU occupancy rate is used to measure the CPU computing power of the mobile terminal. Then, the available physical memory information of the mobile terminal is calculated by the memory size occupied by the running application, and the available physical memory information is used to measure the temporary data storage capacity of the mobile terminal. Then, the network performance index of the mobile terminal is calculated by the network performance index, and the network performance index is used to measure the network carrying capacity of the mobile terminal. Then, the running smoothness of the mobile terminal is calculated by the running loop parameters of the main thread, and the running smoothness is used to measure the screen rendering ability of the mobile terminal. Finally, the target loading resources of the target application are determined by combining the CPU occupancy rate, the available physical memory information, the network performance index and the running smoothness. The present invention can solve the technical problem that the running effects of applications vary greatly in mobile devices with different hardware conditions or network environments.
[0130] See also Figure 4 Another embodiment of the device for running the application in the embodiment of the present invention includes:
[0131] The acquisition module 301 is used to acquire the clock pulse quantity information of the mobile terminal, and calculate the CPU occupancy rate of the mobile terminal according to the clock pulse quantity information;
[0132] A calculation module 302 is used to obtain available physical memory information by calculating the memory occupied by the application programs running on the mobile terminal;
[0133] The collection module 303 is used to collect the network performance indicators of the mobile terminal and calculate the network performance index of the mobile terminal according to the network performance indicators;
[0134] A loop module 304 is used to calculate the running loop parameters of the main thread of the mobile terminal to obtain the running smoothness;
[0135] The running module 305 is used to determine the target loading resources of the target application according to the CPU occupancy rate, the available physical memory information, the network performance index and the running fluency, and run the target application according to the target loading resources.
[0136] Optionally, the acquisition module 301 is specifically used for:
[0137] By using a preset host statistical function, the central processing unit load information of the mobile terminal is counted to obtain the central processing unit load data;
[0138] Extracting clock pulse quantity information from the CPU load data, the clock pulse quantity information including a first clock pulse quantity in a user process mode, a second clock pulse quantity in a kernel process mode, a third clock pulse quantity in an idle mode, and a fourth clock pulse quantity in a wait mode;
[0139] The CPU occupancy rate of the mobile terminal is calculated according to the first clock pulse number, the second clock pulse number, the third clock pulse number and the fourth clock pulse number.
[0140] Optionally, the calculation module 302 is specifically used for:
[0141] Reading firmware parameter information of the mobile terminal, and extracting inherent physical memory information in the firmware parameter information;
[0142] Obtaining the number of application program threads and the number of kernel threads in active state through a preset host statistical function, and calculating the occupied physical memory information of the mobile terminal according to the number of application program threads and the number of kernel threads;
[0143] The available physical memory information of the mobile terminal is calculated according to the inherent physical memory information and the occupied physical memory information.
[0144] Optionally, the acquisition module 303 is specifically used for:
[0145] Inject network performance monitoring scripts into target applications through preset hook functions;
[0146] Collecting network performance indicators of the mobile terminal through the network performance monitoring script, wherein the network performance indicators include connection establishment time, uplink traffic and downlink traffic;
[0147] Based on the connection establishment duration, the uplink traffic, and the downlink traffic, a network performance index of the mobile terminal is calculated.
[0148] Optionally, the circulation module 304 is specifically used for:
[0149] Create a jam monitoring sub-thread, and monitor the running loop parameters of the main thread through the jam monitoring sub-thread to obtain the entry time of each state domain in the main thread;
[0150] Based on the entry time of each state domain in the main thread, the switching time between any two adjacent state domains in the main thread is calculated to obtain the state domain switching duration;
[0151] The running fluency of the mobile terminal is calculated according to the state domain switching duration.
[0152] Optionally, the operation module 305 includes:
[0153] The judgment unit 3051 is used to judge whether the CPU occupancy rate is higher than a preset occupancy rate threshold, whether the available physical memory information is lower than a preset memory threshold, whether the network performance index is lower than a preset performance index threshold, and whether the operation fluency is lower than a preset fluency threshold, to obtain a target judgment result;
[0154] A determination unit 3052, configured to determine a target resource loading level of a target application based on the target determination result;
[0155] The running unit 3053 is used to determine the target loading resource of the target application according to the target resource loading level, and run the target application according to the target loading resource.
[0156] Optionally, the operation unit 3053 is specifically used for:
[0157] Determining whether the target resource loading level is greater than or equal to a preset optimized resource loading level;
[0158] If the target resource loading level is greater than or equal to the preset optimized resource loading level, obtaining optimized resources from the preset loaded resources, and setting the optimized resources as target loaded resources of the target application;
[0159] If the target resource loading level is lower than the preset optimized resource loading level, obtaining the target loading resource according to the target resource loading level;
[0160] The target application is loaded according to the target loading resource.
[0161] In an embodiment of the present invention, the CPU occupancy rate is calculated by the number of clock pulses of the mobile terminal, and the CPU occupancy rate is used to measure the CPU computing power of the mobile terminal. Then, the available physical memory information of the mobile terminal is calculated by the memory size occupied by the running application, and the available physical memory information is used to measure the temporary data storage capacity of the mobile terminal. Then, the network performance index of the mobile terminal is calculated by the network performance index, and the network performance index is used to measure the network carrying capacity of the mobile terminal. Then, the running fluency of the mobile terminal is calculated by the switching time of each state domain in the main thread, and the running fluency is used to measure the screen rendering ability of the mobile terminal. Finally, the target loading resource of the target application is determined by combining the CPU occupancy rate, the available physical memory information, the network performance index and the running fluency. The present invention can solve the technical problem that the running effect of the application is greatly different in mobile devices with different hardware conditions or network environments.
[0162] above Figure 3 and Figure 4 The running device of the application in the embodiment of the present invention is described in detail from the perspective of modular functional entities, and the running device of the application in the embodiment of the present invention is described in detail from the perspective of hardware processing.
[0163] Figure 5 1 is a schematic diagram of the structure of an application program running device provided by an embodiment of the present invention. The application program running device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 510 (for example, one or more processors) and a memory 520, and one or more storage media 530 (for example, one or more mass storage devices) storing application programs 533 or data 532. Among them, the memory 520 and the storage medium 530 may be temporary storage or permanent storage. The program stored in the storage medium 530 may include one or more modules (not shown in the figure), and each module may include a series of computer program operations in the application program running device 500. Furthermore, the processor 510 may be configured to communicate with the storage medium 530 to execute a series of computer program operations in the storage medium 530 on the application program running device 500.
[0164] The application program running device 500 may also include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input and output interfaces 560, and / or one or more operating systems 531, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Figure 5 The illustrated application program running device structure does not constitute a limitation on the application program running device, and may include more or fewer components than illustrated, or a combination of certain components, or a different arrangement of components.
[0165] The present invention also provides a computer device, which includes a memory and a processor, wherein a computer-readable computer program is stored in the memory, and when the computer-readable computer program is executed by the processor, the processor executes the steps of the method for running the application in the above-mentioned embodiments.
[0166] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program runs on a computer, the computer executes the steps of the method for running the application.
[0167] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0168] The blockchain referred to in the present invention is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the blockchain underlying platform, platform product service layer, and application service layer.
[0169] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0170] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially 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. The computer software product is stored in a storage medium, including several computer programs to enable a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0171] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for running an application program, It is characterized in that The method for running the application includes: By using a preset host statistical function, the central processing unit load information of the mobile terminal is counted to obtain the central processing unit load data; Extracting clock pulse quantity information from the CPU load data, the clock pulse quantity information including a first clock pulse quantity in a user process mode, a second clock pulse quantity in a kernel process mode, a third clock pulse quantity in an idle mode, and a fourth clock pulse quantity in a wait mode; Calculating the CPU occupancy rate of the mobile terminal according to the first clock pulse number, the second clock pulse number, the third clock pulse number and the fourth clock pulse number; Obtaining available physical memory information by calculating the memory occupied by the application running on the mobile terminal; Collecting network performance indicators of the mobile terminal, and calculating a network performance index of the mobile terminal according to the network performance indicators; Calculating the running loop parameters of the main thread of the mobile terminal to obtain the running smoothness; Determine whether the CPU occupancy rate is higher than a preset occupancy rate threshold, determine whether the available physical memory information is lower than a preset memory threshold, determine whether the network performance index is lower than a preset performance index threshold, and determine whether the operation fluency is lower than a preset fluency threshold, to obtain a target judgment result; Based on the target determination result, determining a target resource loading level of the target application program; The target loading resources of the target application are determined by the target resource loading level, and the target application is run according to the target loading resources.
2. The method for running an application according to claim 1, It is characterized in that The obtaining of available physical memory information by calculating the memory occupied by the application running on the mobile terminal includes: Reading firmware parameter information of the mobile terminal, and extracting inherent physical memory information in the firmware parameter information; Obtaining the number of application program threads and the number of kernel threads in active state through a preset host statistical function, and calculating the occupied physical memory information of the mobile terminal according to the number of application program threads and the number of kernel threads; The available physical memory information of the mobile terminal is calculated according to the inherent physical memory information and the occupied physical memory information.
3. The method for running an application according to claim 1, It is characterized in that The collecting the network performance indicator of the mobile terminal and calculating the network performance index of the mobile terminal according to the network performance indicator includes: Inject network performance monitoring scripts into target applications through preset hook functions; Collecting network performance indicators of the mobile terminal through the network performance monitoring script, wherein the network performance indicators include connection establishment time, uplink traffic and downlink traffic; Based on the connection establishment duration, the uplink traffic, and the downlink traffic, a network performance index of the mobile terminal is calculated.
4. The method for running an application according to claim 1, It is characterized in that The calculating of the running cycle parameters of the main thread of the mobile terminal to obtain the running fluency includes: Create a jam monitoring sub-thread, and monitor the running loop parameters of the main thread through the jam monitoring sub-thread to obtain the entry time of each state domain in the main thread; Based on the entry time of each state domain in the main thread, the switching time between any two adjacent state domains in the main thread is calculated to obtain the state domain switching duration; The running fluency of the mobile terminal is calculated according to the state domain switching duration.
5. The method for running an application according to claim 1, It is characterized in that The step of determining the target loading resource of the target application program according to the target resource loading level, and running the target application program according to the target loading resource, comprises: Determining whether the target resource loading level is greater than or equal to a preset optimized resource loading level; If the target resource loading level is greater than or equal to the preset optimized resource loading level, obtaining optimized resources from the preset loaded resources, and setting the optimized resources as target loaded resources of the target application; If the target resource loading level is lower than the preset optimized resource loading level, obtaining the target loading resource according to the target resource loading level; The target application is loaded according to the target loading resource.
6. A device for running an application program, It is characterized in that The application program running device includes: An acquisition module is used to count the CPU load information of the mobile terminal through a preset host statistical function to obtain CPU load data; extract clock pulse quantity information in the CPU load data, wherein the clock pulse quantity information includes a first clock pulse quantity in a user process mode, a second clock pulse quantity in a kernel process mode, a third clock pulse quantity in an idle mode, and a fourth clock pulse quantity in a waiting mode; and calculate the CPU occupancy rate of the mobile terminal according to the first clock pulse quantity, the second clock pulse quantity, the third clock pulse quantity, and the fourth clock pulse quantity; A calculation module, used to obtain available physical memory information by calculating the memory occupied by the application programs running on the mobile terminal; A collection module, used to collect the network performance indicators of the mobile terminal, and calculate the network performance index of the mobile terminal according to the network performance indicators; A loop module, used to calculate the running loop parameters of the main thread of the mobile terminal to obtain the running smoothness; An operation module is used to determine whether the CPU occupancy rate is higher than a preset occupancy rate threshold, determine whether the available physical memory information is lower than a preset memory threshold, determine whether the network performance index is lower than a preset performance index threshold, and determine whether the operation fluency is lower than a preset fluency threshold, and obtain a target judgment result; based on the target judgment result, determine a target resource loading level of a target application; through the target resource loading level, determine a target loading resource of the target application, and run the target application according to the target loading resource.
7. A device for running an application program, It is characterized in that The application program running device includes: a memory and at least one processor, wherein the memory stores a computer program; The at least one processor calls the computer program in the memory so that the application program execution device executes the application program execution method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the method for running the application program according to any one of claims 1 to 5 is implemented.
