Disclosure of Invention
The embodiment of the invention provides a method and a device for determining the duration of starting an application program and a storage medium, which are used for at least solving the technical problem that the starting time is inaccurate when a CPU starts the application program in the related technology.
According to one embodiment of the present invention, there is provided a method for determining a duration of starting an application program, including: acquiring starting information of an application program, wherein the starting information comprises at least one of the following: the current utilization rate of the CPU, the memory occupancy rate and the process information of the application program; determining historical starting time length information of the application program according to the starting information; and determining the time length of the CPU for currently starting the application program by using the historical starting time length information.
Optionally, determining the historical starting duration information of the application program according to the starting information includes: and when the starting information is matched with the recorded historical starting time length of the application program, the historical starting time length is used as the historical starting time length information.
Optionally, determining the duration of the current start of the application program by the CPU using the historical start duration information includes: when the number of the historical starting time length information is larger than a preset number, classifying the historical starting time length information according to time length; determining the most numerous classifications that include the historical activation time information; determining average starting time or central starting time of the application program according to a plurality of the historical starting time information in the classification; and taking the average starting time or the central starting time as the duration of the current starting of the application program by the CPU.
Optionally, determining the duration of the current start of the application program by the CPU using the historical start duration information includes: when the number of the historical starting duration information is smaller than or equal to a preset number, reading a preset value of the starting time of the application program; and taking the preset value as the duration of the current starting of the application program by the CPU.
Optionally, after determining the duration of the CPU currently starting the application program by using the historical starting duration information, the method further includes: and controlling the CPU to start the application program on a preset frequency and a preset core number according to the determined time length for the CPU to start the application program currently.
Optionally, after determining the duration of the CPU currently starting the application program by using the historical starting duration information, the method further includes: and recording the duration of the current starting of the application program by the CPU.
According to another embodiment of the present invention, there is also provided a device for determining a duration of starting an application program, including: the system comprises an acquisition module, a control module and a control module, wherein the acquisition module is used for acquiring starting information of an application program, and the starting information comprises at least one of the following components: the current utilization rate of the CPU, the memory occupancy rate and the process information of the application program; the first determining module is used for determining historical starting duration information of the application program according to the starting information; and the second determining module is used for determining the duration of the current starting of the application program by the CPU by utilizing the historical starting duration information.
Optionally, the first determining module includes: the first processing unit is used for taking the historical starting duration as the historical starting duration information when the starting information is matched with the recorded historical starting duration of the application program.
Optionally, the second determining module includes: the classification unit is used for classifying the historical starting duration information according to duration when the number of the historical starting duration information is larger than a preset number; a first determining unit configured to determine a category that includes the most number of the historical activation time period information; a second determining unit, configured to determine an average start-up time or a center start-up time of the application program according to a plurality of the historical start-up time information in the classification; and the second processing unit is used for taking the average starting time or the central starting time as the duration of the current starting of the application program by the CPU.
Optionally, the second determining module includes: a reading unit, configured to read a preset value of the application program start time when the number of the historical start time information is less than or equal to a predetermined number; and the third processing unit is used for taking the preset value as the duration of the current starting of the application program by the CPU.
Optionally, the apparatus further comprises: and the control module is used for controlling the CPU to start the application program on a preset frequency and a preset core number according to the determined duration of the CPU currently starting the application program after the duration of the CPU currently starting the application program is determined by utilizing the historical starting duration information.
According to yet another embodiment of the present invention, there is also provided a storage medium including a stored program, wherein the program, when run, performs the method of any one of the above.
According to yet another embodiment of the present invention, there is also provided a processor for running a program, wherein the program when run performs the method of any of the above.
According to the invention, after the starting information of the application program is obtained, the starting information comprises at least one of the following: the current utilization rate of the CPU, the memory occupancy rate and the process information of the application program; determining historical starting time length information of the application program according to the starting information; and determining the time length of the CPU for currently starting the application program by using the historical starting time length information. Therefore, the application program can be started according to the determined time length, the technical problem that the starting time is inaccurate when the CPU starts the application program in the related technology is solved, and the effect of more accurately determining the starting time of the application program is achieved.
Detailed Description
The invention will be described in detail hereinafter with reference to the drawings in conjunction with embodiments. It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order.
The method embodiments provided by the embodiments of the present application may be performed in a mobile terminal, a computer terminal, or similar computing device. Taking a mobile terminal as an example, fig. 1 is a block diagram of a hardware structure of a mobile terminal according to a method for determining a duration of starting an application according to an embodiment of the present invention. As shown in fig. 1, the mobile terminal 10 may include one or more (only one is shown in fig. 1) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. It will be appreciated by those of ordinary skill in the art that the configuration shown in fig. 1 is merely illustrative and is not intended to limit the configuration of the electronic device described above. For example, the mobile terminal 10 may also include more or fewer components than shown in FIG. 1 or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store software programs and modules of application software, such as program instructions/modules corresponding to a method for determining a duration of starting an application program in an embodiment of the present invention, and the processor 102 executes the software programs and modules stored in the memory 104, thereby performing various functional applications and data processing, that is, implementing the method described above. Memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission means 106 is arranged to receive or transmit data via a network. The specific examples of networks described above may include wireless networks provided by the communication provider of the mobile terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module for communicating with the internet wirelessly.
In this embodiment, a method for determining a duration of starting an application program is provided, and fig. 2 is a flowchart of a method for determining a duration of starting an application program according to an embodiment of the present invention, as shown in fig. 2, where the flowchart includes the following steps:
step S202, acquiring starting information of an application program, wherein the starting information comprises at least one of the following steps: the current utilization rate of the CPU, the memory occupancy rate and the process information of the application program;
step S204, determining historical starting time length information of the application program according to the starting information; and determining the current starting time of the CPU to start the application program by using the historical starting time information.
After the starting information of the application program is obtained through the steps, the starting information comprises at least one of the following steps: the current utilization rate of the CPU, the memory occupancy rate and the process information of the application program; determining historical starting time length information of the application program according to the starting information; and determining the time length of the CPU for currently starting the application program by using the historical starting time length information. Therefore, the application program can be started according to the determined time length, the technical problem that the starting time is inaccurate when the CPU starts the application program in the related technology is solved, and the effect of more accurately determining the starting time of the application program is achieved.
Alternatively, the execution subject of the above steps may be a terminal or the like, but is not limited thereto.
In this embodiment, the memory occupancy rate refers to the memory occupancy rate of the entire device.
In an alternative embodiment, determining the historical starting duration information of the application program according to the starting information includes: and when the starting information is matched with the recorded historical starting time length of the application program, the historical starting time length is used as the historical starting time length information. In the present embodiment, the information included in the start time described above may also include other information, and is not limited to the information described above.
In an alternative embodiment, determining the duration of the CPU currently starting the application program using the historical starting duration information includes: when the number of the historical starting time length information is larger than a preset number, classifying the historical starting time length information according to time length; determining the most number of classifications comprising the above-mentioned historical starting time length information; determining average starting time or central starting time of the application program according to a plurality of the historical starting time information in the classification; and taking the average starting time or the central starting time as the duration of the CPU for currently starting the application program. In this embodiment, the classification may be performed according to a clustering algorithm, or may be performed according to another algorithm.
In an alternative embodiment, determining the duration of the CPU currently starting the application program using the historical starting duration information includes: when the number of the historical starting time information is smaller than or equal to a preset number, reading a preset value of the starting time of the application program; and taking the preset value as the time length for the CPU to start the application program currently. In this embodiment, the preset value may be a default value of the system when the application is started, or may be set.
In an optional embodiment, after determining the duration of the CPU currently starting the application program using the historical starting duration information, the method further includes: and controlling the CPU to start the application program at a preset frequency and a preset core number according to the determined time period for the CPU to start the application program currently. In this embodiment, the predetermined frequency may be 2GHZ and the predetermined number of nuclei may be 8 nuclei.
In an optional embodiment, after determining the duration of the CPU currently starting the application program using the historical starting duration information, the method further includes: and recording the current starting time of the application program by the CPU. In this embodiment, the recorded duration is used for reference information for starting the application program later.
The invention will be described in detail with reference to specific examples below:
specific example 1:
the embodiment describes a method for controlling the frequency of a processor, before the application program is cold started, the current CPU utilization rate, the memory utilization rate, whether the application related process is started or not and other information are obtained, according to the conditions, the historical starting time under the conditions is analyzed, a clustering algorithm is applied, data is divided into n types, the average value of the most data is calculated for the most data types, the average value is set to be that the cores of a certain number of cores of the CPU are opened when the application program is cold started, and the duration of the CPU at a certain fixed frequency is set. The embodiment combines the main factors influencing the application starting, and applies the clustering algorithm to enable the application starting time estimation to be more accurate, so that the user experience can be improved, and the power consumption can be effectively controlled.
After the terminal is started, when the application is started, the background does not have a process of the application, and the system can recreate a new process to be distributed to the application. If the background has a process of the application when the application is started, starting from the existing process, wherein the starting mode is hot starting. When the Application is cold started on the android system, the system can separate a fork from a zygate process to create a new process to be distributed to the Application, then an Application class can be created sequentially, a main activity MainActivity class is created, and the like, the whole process consumes more CPU resources, at the moment, a certain number of cores of the CPU are opened, and the CPU works at a certain higher frequency, so that the Application cold starting time can be greatly shortened. This embodiment is used for such a scenario.
The zygate process is described below: in the Android system, all application program processes and system service process systemservers are out of the zygate process branch (fork). In Java, different virtual machine instances allocate different memory for different applications. If the Android applications should be started as fast as possible, but if the Android system starts different Dalvik virtual machine instances for each application, a lot of memory and time is consumed. Zygate enables Dalvik virtual machines to share code, low memory usage, and minimal boot time. Zygate is a virtualizer process that starts at system boot time. Zygate preloads and initializes core library classes. Typically, these core classes are typically read-only, as well as part of the Android SDK or core framework. In a Java virtual machine, each instance has its own copy of the core library class file and heap objects.
Fig. 3 is a schematic diagram of an apparatus for controlling processor frequency in the present embodiment, and as shown in fig. 3, the system includes a processor S301, an internal memory S302, an external memory S303, and a bus S304.
The bus S304 is used to connect the processor S301, the internal memory S302, and the external memory S303.
The external memory S303 stores an application execution file; application name, application history cold start time; the default should be cold-started.
When the application is started, the processor S301 reads a preset default value for cold start in the external memory S303 or a time corresponding to the application for a last cold start, which are temporarily stored in the internal memory S302, and the processor S301 sets the time value to a corresponding register of the processor S301.
Fig. 4 is a flowchart of a processor frequency control method in the present embodiment, as shown in fig. 4, the flowchart specifically includes:
in step S401, the user cold starts a certain application.
Step S402, the CPU and the memory occupancy rate of the current device are obtained, and data which possibly affect the cold start of the application, such as the number of processes related to the application, are obtained.
Step S403, reading the historical starting duration data corresponding to the current condition, comparing with the classification number to be classified, and if n is to be classified, at least n+1 pieces of data are needed to be valid, wherein n is greater than or equal to 1.
In step S404, if the historical duration data is less than n+1 pieces, the default configuration idea start time is used.
Step S405, reading all the history duration data under the corresponding conditions.
Step S406, the read data is classified.
In step S407, the most data class is taken, and the mean or center point of such data class is calculated.
In step S408, the average value of the time periods calculated in S407 is set as the time period in which the CPU runs on a specific frequency on some cores.
In step S409, the application starts to start.
Step S410, recording the cold start duration of the application.
Specific example 2:
the embodiment is described in detail by taking cold start as an example, and specifically includes the following steps:
in step S101, the user cold starts an application, and a common manner is to click a touch screen or a key.
In step S102, the general application starting speed is mainly related to the CPU occupancy rate, the memory occupancy rate, and the like, and on Android, some applications have background services, and these processes are started when starting up, and the application is dependent on these processes when cold starting up, but if these background processes are not started or have been killed, when the application is started up, the service is started first, and then the main thread is started, so that the starting time of the application is long, and the first several pieces of information of the general process name are the same. The background dependent services have a significant impact on the start-up speed, so the background process must be counted.
Step S103, according to the conditions in step S102, searching all the historical data meeting the conditions, and judging whether the historical data meets the classification requirement, for example, n classes are needed, preferably n+1 data are needed, so that the classification with the most data is conveniently selected.
Step S104, if the number of data does not meet n+1, reading a default time length value configured in advance, sequentially configuring time length for the CPU to work under a special condition in S108, and starting the application.
Step S105, classifying the history data read in step S103 by a clustering algorithm, and classifying the history data into n types, such as 3 types. The clustering algorithm is more, and the K-MEANS algorithm can be selected. Firstly, arbitrarily selecting k objects from n data objects as initial clustering centers; for the remaining other objects, they are respectively assigned to clusters (represented by the cluster centers) most similar to the other objects according to their similarity (distance) to the cluster centers; then calculating the cluster center (the average value of all objects in the cluster) of each obtained new cluster; this process is repeated until the standard measure function begins to converge. K-MEDOIDS can also be selected, which is insensitive to dirty data and abnormal data, but has a larger calculation amount than the K-MEANS algorithm.
Step S107, after the classification is completed, the data is classified into the class with the most data, the average value of all data classified is calculated, the average value is taken as the duration to be configured in S108,
the center point of the data in the classification can also be found, and the sum of the distances from this point to all other points is the smallest, so that the data is insensitive to dirty data and abnormal data.
Step S108, the calculated values of the step S107 are used as the duration that the CPU is about to run in a certain special configuration, and parameters such as the number of cores to be run, frequency and the like can be configured according to different CPU types.
Step S109, a normal cold application start-up procedure is started.
Step S110, the time length of the application start is recorded, and the time length of the next application cold start is used as a reference.
The method can also be used for training the known application, and comparing the time length set in the S108 with the actual starting time length of the S110 until the two values meet a certain error, and considering that the determined value is acquired, and the time length is used as the fixed starting time length under the condition to be configured into a formal version, so that the classification calculation time can be saved.
In summary, the application starting speed can be improved by determining the running time of the CPU. And can reduce power consumption and heat generation.
The embodiments described above are applicable to other embedded devices as well. And, other new algorithms can be used to count the time the CPU is operating at the highest frequency when the pre-estimated application is started.
From the description of the above embodiments, it will be clear to a person skilled in the art that the method according to the above embodiments may be implemented by means of software plus the necessary general hardware platform, but of course also by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The embodiment also provides a device for determining the duration of starting the application program, which is used for implementing the above embodiment and the preferred implementation, and is not described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
Fig. 5 is a block diagram of a configuration of a device for determining a duration of starting an application according to an embodiment of the present invention, as shown in fig. 5, the device including: an acquisition module 502, a first determination module 504 and a second determination module 506. The device will be described in detail below.
An obtaining module 502, configured to obtain start information of an application, where the start information includes at least one of the following: the current utilization rate of the CPU, the memory occupancy rate and the process information of the application program; a first determining module 504, coupled to the acquiring module 502, configured to determine historical starting duration information of the application according to the starting information; a second determining module 506, coupled to the first determining module 504, configured to determine a duration of the CPU currently starting the application program using the historical starting duration information.
In an alternative embodiment, the first determining module 504 includes: the first processing unit is used for taking the historical starting time length as the historical starting time length information when the starting information is matched with the recorded historical starting time length.
In an alternative embodiment, the second determining module 506 includes: the classification unit is used for classifying the historical starting duration information according to duration when the number of the historical starting duration information is larger than a preset number; a first determining unit configured to determine a category having the largest number of pieces of the above-described historical activation time length information; a second determining unit configured to determine an average start-up time or a center start-up time of the application program according to a plurality of the historical start-up time information in the classification; and the second processing unit is used for taking the average starting time or the central starting time as the duration of the current starting of the application program by the CPU.
In an alternative embodiment, the second determining module 506 includes: a reading unit, configured to read a preset value of the application program start time when the number of the historical start time information is less than or equal to a predetermined number; and the third processing unit is used for taking the preset value as the time length for the CPU to start the application program currently.
In an alternative embodiment, the apparatus further comprises: and the control module is used for controlling the CPU to start the application program on a preset frequency and a preset core number according to the determined time length for the CPU to start the application program currently after the time length for the CPU to start the application program currently is determined by using the historical starting time length information.
In an alternative embodiment, the apparatus further comprises: and the recording module is used for recording the duration of the current starting of the application program by the CPU after the duration of the current starting of the application program by the CPU is determined by using the historical starting duration information.
It should be noted that each of the above modules may be implemented by software or hardware, and for the latter, it may be implemented by, but not limited to: the modules are all located in the same processor; alternatively, the above modules may be located in different processors in any combination.
An embodiment of the present invention also provides a storage medium including a stored program, where the program executes the method of any one of the above.
Alternatively, in the present embodiment, the above-described storage medium may be configured to store the program code for performing the above steps.
Alternatively, in the present embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Embodiments of the present invention also provide a processor for running a program, wherein the program when run performs the steps of any of the methods described above.
Alternatively, specific examples in this embodiment may refer to examples described in the foregoing embodiments and optional implementations, and this embodiment is not described herein.
It will be appreciated by those skilled in the art that the modules or steps of the invention described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, they may alternatively be implemented in program code executable by computing devices, so that they may be stored in a memory device for execution by computing devices, and in some cases, the steps shown or described may be performed in a different order than that shown or described, or they may be separately fabricated into individual integrated circuit modules, or multiple modules or steps within them may be fabricated into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention should be included in the protection scope of the present invention.