WO2021129489A1 - 应用程序预编译的方法、装置、电子设备及存储介质 - Google Patents

应用程序预编译的方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2021129489A1
WO2021129489A1 PCT/CN2020/136887 CN2020136887W WO2021129489A1 WO 2021129489 A1 WO2021129489 A1 WO 2021129489A1 CN 2020136887 W CN2020136887 W CN 2020136887W WO 2021129489 A1 WO2021129489 A1 WO 2021129489A1
Authority
WO
WIPO (PCT)
Prior art keywords
electronic device
compilation
application
hotspot
state
Prior art date
Application number
PCT/CN2020/136887
Other languages
English (en)
French (fr)
Inventor
帅朝春
Original Assignee
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2021129489A1 publication Critical patent/WO2021129489A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Definitions

  • This application relates to the field of computer technology, and more specifically, to a method, device, electronic device, and storage medium for pre-compiling an application program.
  • the operating efficiency of the application program can be improved to a certain extent by way of pre-compilation.
  • the related compilation method will affect the operating performance of the electronic device and reduce the user experience.
  • this application proposes a method, device, electronic device and storage medium for application program pre-compilation to improve the above-mentioned problems.
  • this application provides a method for pre-compilation of an application, applied to an electronic device, the method includes: detecting the current operating state of the electronic device; if the operating state meets a specified condition, and the application is in During the installation phase, a configuration file corresponding to the application program is acquired, and the hotspot compilation unit corresponding to the application program is stored in the configuration file; and the hotspot compilation unit is pre-compiled.
  • the present application provides a device for pre-compilation of an application program, which runs on an electronic device, and the device includes: a state detection unit for detecting the current operating state of the electronic device; and an information acquisition unit for When the running state meets the specified conditions and the application program is in the installation phase, the configuration file corresponding to the application program is obtained, and the hotspot compilation unit corresponding to the application program is stored in the configuration file; The hotspot compilation unit performs pre-compilation.
  • this application provides an electronic device including one or more processors and a memory; one or more programs, wherein the one or more programs are stored in the memory and configured to be The one or more processors execute, and the one or more programs are configured to execute the above-mentioned methods.
  • the present application provides a computer-readable storage medium in which program code is stored, wherein the above-mentioned method is executed when the program code is running.
  • FIG. 1 shows a schematic diagram of the operating environment of a method for pre-compiling an application program proposed in an embodiment of the present application.
  • FIG. 2 shows a schematic diagram of the operating environment of another method for precompiling an application program proposed in an embodiment of the present application.
  • FIG. 3 shows a schematic diagram of the operating environment of still another method for precompiling an application program proposed in an embodiment of the present application.
  • Fig. 4 shows a flow chart of a method for pre-compiling an application program proposed in an embodiment of the present application.
  • Fig. 5 shows a flow chart of a method for pre-compiling an application program according to another embodiment of the present application.
  • Fig. 6 shows a flow chart of a method for pre-compiling an application program according to another embodiment of the present application.
  • Fig. 7 shows a flowchart of a method for pre-compiling an application program proposed by another embodiment of the present application.
  • Fig. 8 shows a structural block diagram of a device for pre-compiling an application program proposed in this application.
  • Fig. 9 shows a structural block diagram of another apparatus for pre-compiling an application program proposed by the present application.
  • Fig. 10 shows a structural block diagram of an electronic device of the present application for executing the method for pre-compiling an application program according to an embodiment of the present application.
  • FIG. 11 is a storage unit for storing or carrying program code for implementing the method for pre-compiling an application program according to an embodiment of the present application according to an embodiment of the present application.
  • the application in the electronic device can be directly parsed and executed by the interpreter at runtime.
  • the number of calls and cycles of each compilation unit is recorded.
  • the corresponding compilation unit is recorded as a hotspot compilation unit.
  • the compilation unit can be understood as a function, method, or class in the source code of the application.
  • the hotspot compilation unit will be identified, compiled by JIT (Just In Time, just-in-time compilation), and then stored and a profile file is generated to record the information of the hotspot compilation unit.
  • JIT Just In Time, just-in-time compilation
  • the system of the electronic device scans the profile file and executes the AOT (Ahead Of Time, pre-compilation) process to compile.
  • AOT Ahead Of Time, pre-compilation
  • the hotspot compilation unit corresponding to the application may be downloaded with the installation package of the application at the same time. If the installation package of the application itself is large, it will be more expensive.
  • the processing resources of multiple electronic devices are used to install the installation package, but if the pre-compilation operation of the hot compilation unit is still performed during the installation phase, the installation process of the installation package may be prolonged and the user experience may be reduced.
  • a method, device, electronic device, and storage medium for application pre-compilation provided by the application are proposed.
  • the application program When the application program is installed, the current operating state of the electronic device is detected, and if the operating state meets the specified conditions, Obtain the configuration file corresponding to the application and storing the hotspot compilation unit corresponding to the application, and precompile the hotspot compilation unit. Therefore, by detecting the operating status of the electronic device during the application installation phase, the pre-compilation operation of the hotspot compilation unit in the configuration file is performed only when the operating status meets the specified conditions, so that the compilation timing of the hotspot compilation unit is configurable , Instead of directly compiling the hotspot compilation unit at the application installation stage, the operating performance of the electronic device will be affected.
  • FIG. 1 Please refer to FIG. 1.
  • multiple electronic devices 100 and servers 200 are included.
  • multiple electronic devices 100 exchange data with the server 200 through the network.
  • a target application program is running in multiple electronic devices 100, and the target application program running in each electronic device 100 is correspondingly generated with a configuration file (which may be the aforementioned profile file) 120.
  • multiple electronic devices 100 can upload the configuration file 120 of the target application installed by themselves to the server 200, so that the server can obtain multiple configuration files 120 corresponding to the target application, and then configure the multiple configuration files 120.
  • the file 120 undergoes fusion processing, extracts the multiple hotspot compilation units included in the multiple configuration files 120, and then obtains the configuration file 210 including the multiple hotspot compilation units, and then returns the configuration files 210 to the multiple electronic devices 100 respectively. .
  • the multiple hotspot compilation units may be hotspot compilation units after deduplication of the multiple configuration files 120, or may be hotspot compilation units whose compilation times exceed the threshold among all the hotspot compilation units in the multiple configuration files 120, or may be Specify the hotspot compilation unit corresponding to the function module.
  • the server 200 can also directly send the configuration file 210 and the program installation package 230 of the target application installation program 220 to the electronic device 130 that has not yet installed the target application, so that the electronic device When the target application 130 is installed, the configuration file 210 can be run to perform pre-compilation of some hotspot compilation units.
  • the electronic device 130 may also determine the running time of the configuration file 210 according to the current running state.
  • the server that collects multiple configuration files 120 and processes the multiple configuration files 120 to obtain the configuration file 210 may be a single server or a server cluster.
  • the server that collects multiple configuration files 120 and processes the multiple configuration files 120 to obtain the configuration file 210 may be a different server from the server that subsequently issues the program installation package 230.
  • the server 200 is only used to perform the aforementioned collection of configuration files uploaded by multiple electronic devices 100, and then send the collected configuration files to the server 201.
  • the server 201 executes the extraction of the multiple hotspot compilation units included in the multiple configuration files 120, and then obtains the configuration file 210 based on the multiple hotspot compilation units, and then returns the configuration files 210 to the multiple electronic devices 100 respectively.
  • the server 201 may also send the generated configuration file 210 to the server 200, and then the server 200 forwards it to multiple electronic devices 100 (not shown in the figure).
  • the server 201 can directly run an application distribution platform. In this case, the server 201 can directly configure the configuration file 210 in the program installation package 230 and send it to the electronic device that has not yet installed the target application. 130.
  • the server 201 can send the configuration file 210 to the application distribution platform, so that the application distribution platform configures the configuration file 210 in the program installation package 230 and sends it to the electronics that have not yet installed the target application. Equipment 130.
  • the configuration file mentioned in the subsequent embodiments may be the configuration file 210.
  • the hotspot compilation unit in the newly generated configuration file 210 may be a hotspot compilation unit compiled by the server 200, or a hotspot compilation unit that has not been compiled yet.
  • the electronic device that receives the newly generated configuration file 210 may compile before running the target application, or install Compile the target application.
  • a hotspot compiling unit compiled for the server 200 it may be a hotspot compiling unit compiled by the server 200 based on the hardware environment of the electronic device to be distributed.
  • a method for pre-compilation of an application program provided by the present application is applied to an electronic device, and the method includes:
  • Step S110 Detect the current operating state of the electronic device.
  • the electronic device when the electronic device obtains the installation file of the application from the server, in addition to the installation program of the application itself, the obtained installation file may also carry the configuration file corresponding to the application.
  • the configuration file may be the configuration file 210 in the foregoing introduction.
  • the hotspot compilation unit corresponding to the application program can also be stored in other areas (that is, in the server where the application program installation package is not stored).
  • the electronic device is When the file server initiates an installation file request, the server storing the installation file can return a redirection message to the server storing the configuration file to the electronic device, so that the electronic device will also initiate the configuration file to the server storing the configuration file. request. Then in this case, as a way, the electronic device can trigger the installation phase of the application after receiving the installation file and the configuration file, so that the electronic device can realize the pre-compilation hotspot during the process of running the installation file. Compilation unit.
  • the operating state of the electronic device may include multiple states.
  • the operating state of the electronic device may include the hardware state. It is understandable that the hardware devices such as the processor (CPU), graphics processing unit (GPU), and memory included in the electronic device will be in the running state during the operation of the electronic device to complete the data processing and data reading during the operation of the electronic device. Write operation. However, if the hardware device of the electronic device is operating at a higher frequency, the operating efficiency of the electronic device may be affected. Exemplarily, if the installation process is an installation process of an application program, the electronic device will decompress the installation package and create a corresponding directory, and even includes a process of processing files obtained by decompressing the installation package. If in this process, the processing resources of the processor are excessively occupied, the installation process of the application program will be prolonged.
  • the hardware devices such as the processor (CPU), graphics processing unit (GPU), and memory included in the electronic device will be in the running state during the operation of the electronic device to complete the data processing and data reading during the operation of the electronic device. Write operation.
  • the processor still has more processing resources even during the installation of the application, then even if other data processing operations are performed, it may have less impact on the installation process of the application .
  • the operating state may include the remaining processing resources of the processor. If it is detected that the remaining processing resources are not less than the specified resource threshold, it indicates that the operating state satisfies the specified condition. Thus, in this way, it is possible to perform the compilation operation of the hotspot compilation unit only when it is detected that the remaining processing resources are not less than the specified resource threshold during the installation stage, so as not to affect the operating performance of the electronic device.
  • the operating state of the electronic device may include the state of the hardware device.
  • the electronic device may include hardware devices such as screens and sensors.
  • the different motion states of the hardware devices may indicate different usage states of users. For example, if the sensor includes a distance sensor arranged near the front camera, and the distance sensor detects that the distance value is less than the specified distance threshold, it indicates that the user is currently in the state of answering a call. For another example, if the screen is currently in the off-screen state, it can indicate that the user is not currently paying attention to the electronic device. Then, in this case, the operating state of the electronic device may include the operating state of the screen.
  • the pre-compilation operation of the hotspot compilation unit can be performed without the user paying attention to the electronic device, so as to reduce the interference of the pre-compilation operation of the hot-spot compilation unit on the user's use of the electronic device.
  • the operating state of the electronic device may include a software state. It should be noted that the electronic device can run multiple applications at the same time, and the more the number of applications currently in the running state, the slower the rate at which the electronic device performs another data processing task. In this manner, the running state of the electronic device may include the number of applications currently in running state.
  • the operating state of the electronic device may include one or more of the aforementioned methods. It should be noted that, in some cases, it is impossible to more accurately determine the current operating state of the electronic device by simply using one of the foregoing operating state judgment methods. Exemplarily, some applications in the electronic device can run in the background, or even run in the off-screen state, then if the electronic device detects that it is currently in the off-screen state, it directly determines that the operating state of the electronic device meets the specified conditions, but In the case that the application program currently running in the background will occupy more data processing resources, it may cause the electronic device to perform the compilation process of the hotspot compilation unit, which further causes the performance of the electronic device to decrease.
  • the electronic device detects that it is currently in the off-screen state, but the remaining processing resources of the processor are 10% of the processing resources, then if the electronic device alone determines that the operating state of the electronic device meets the specified conditions because the electronic device is in the off-screen state, then It will trigger the subsequent compilation operation of the hotspot compilation unit, which in turn will cause the remaining processing resources of the processor to be reduced to a lower level, which will inevitably affect other data processing operations performed by the electronic device in the off-screen state.
  • the operating state of the electronic device may include the operating state of the hardware device and the hardware state.
  • the electronic device may determine that the operating state of the electronic device satisfies the specified condition when it is detected that it is currently in the screen state and the remaining processing resources are not lower than a specified threshold.
  • the specified threshold is lower than the aforementioned specified resource threshold. It should be noted that when the electronic device is in the off-screen state, the user has a greater probability of not paying attention to the operating state of the electronic device. In this case, there is no need to strictly limit the remaining processing resources, that is, the The specified threshold value in the case of judging the running state and the hardware state may be lower than the specified resource threshold value in the case that the hardware state alone is used as the basis for judgment.
  • the electronic device can configure the content of the specified condition according to whether it is in the application installation.
  • the specified condition includes: the electronic device is in an off-screen state; if the application is not in the installation phase, the specified condition includes: the power of the electronic device At least one of meeting the specified power threshold, the available storage space of the electronic device is not less than the specified space threshold, and the temperature of the electronic device is not higher than the specified temperature threshold.
  • Step S120 If the running state meets the specified condition and the application is in the installation stage, obtain a configuration file corresponding to the application, and the configuration file stores a hotspot compilation unit corresponding to the application.
  • the installation phase can be understood as the installation phase of the application program, and can also be understood as the installation phase of the update file of the application program.
  • the electronic device detects that the operating state meets the specified conditions, it means that even if the electronic device currently performs the pre-compilation operation of the hotspot compilation unit at the same time, it will not make the remaining processing resources of the electronic device too tight and cause the operation of the electronic device Performance is affected, or it means that even if the current pre-compilation operation of the hot-spot compilation unit is performed on the electronic device at the same time, the remaining processing resources of the electronic device are too tight, but because the user is not paying attention to the electronic device, it will not be for the user. Perceive that the remaining processing resources are too tight, which affects the operating performance of the electronic device.
  • Step S121 Pre-compiling the hotspot coding unit.
  • the configuration file obtained by the electronic device in step S120 is a configuration file that has not been compiled, that is, it can be understood as a dex file.
  • the pre-compilation operation of the configuration file can be understood as performing AOT compilation, that is, the configuration file in the dex format is pre-compiled and converted into a file in the oat or odex format.
  • Step S130 If the operating state does not meet the specified condition, periodically check whether the electronic device meets the specified condition, until it is detected that the electronic device meets the specified condition, and precompile the hotspot compilation unit .
  • This application provides a method for pre-compilation of an application program, when it is detected that the running state of the electronic device meets a specified condition and the application program is in the installation stage, the corresponding application program corresponding to the application program is obtained
  • the configuration file of the hotspot compilation unit is pre-compiled for the hotspot compilation unit. Therefore, by detecting the running state of the electronic device, the pre-compilation operation of the hotspot compilation unit in the configuration file is performed only when the running state meets the specified conditions, so that the compilation timing of the hotspot compilation unit is configurable, and not directly Compiling the hotspot compiling unit directly during the application program installation stage affects the running performance of the electronic device.
  • a method for pre-compilation of an application program provided by the present application is applied to an electronic device, and the method includes:
  • Step S201 Detect the current operating state of the electronic device.
  • Step S202 If the running state meets the specified condition and the application is in the installation stage, obtain a configuration file corresponding to the application, and the configuration file stores a hotspot compilation unit corresponding to the application.
  • Step S203 Perform pre-compilation on the hotspot coding unit.
  • Step S204 If the running state does not meet the specified condition and the application is in the installation stage, the hotspot compilation unit is not pre-compiled.
  • Step S205 If the running state meets the specified condition and the configuration file of the application program is not pre-compiled during the installation phase, obtain the configuration file corresponding to the application program.
  • Step S206 Pre-compiling the hotspot coding unit.
  • the hotspot compilation unit if it is detected that the operating state of the electronic device is switched to a state that does not meet the specified condition, continue to complete the configuration of the application
  • the remaining uncompiled hotspot compiling units in the file are compiled; the compiling sequence is suspended and the configuration file of the application compiled after the application is compiled; in the suspended state, when it is detected that the electronic device satisfies the specified condition, Resuming the compilation of the configuration file of the application program that was compiled after the application program.
  • the application pre-compilation method provided by the present application detects the running state of the electronic device so that the pre-compilation operation of the hotspot compilation unit in the configuration file is performed only when the running state meets the specified conditions, so that the hotspot compilation unit
  • the compilation timing is configurable, instead of directly compiling the hotspot compilation unit during the application installation phase, which will affect the operating performance of the electronic device.
  • the subsequent pre-compilation operation of the configuration file of the application program can be suspended in time, thereby avoiding the compilation operation in time Cause interference to users.
  • a method for pre-compilation of an application program provided by the present application is applied to an electronic device, and the method includes:
  • Step S210 When detecting the current operating state of the electronic device.
  • Step S220 If the operating state does not meet the specified condition, periodically check whether the electronic device meets the specified condition, until it is detected that the electronic device satisfies the specified condition, and precompile the hotspot compilation unit .
  • Step S230 If the running state meets the specified condition and the application is in the installation phase, obtain a configuration file corresponding to the application, and the configuration file stores a hotspot compilation unit corresponding to the application.
  • Step S240 Perform pre-compilation on the hotspot coding unit.
  • Step S250 During the pre-compilation of the hotspot compilation unit, if it is detected that the operating state of the electronic device is switched to a state that does not meet the specified condition, the compilation of the remaining uncompiled hotspot compilation units is suspended .
  • the operating state of the electronic device may change suddenly, although it is because the operating state of the electronic device meets the specified conditions that the compilation operation of the hotspot compilation unit in the configuration file is triggered.
  • the operating state of the electronic device may change to not satisfy the specified conditions. In this case, in order to avoid the pre-compilation operation from affecting the user's use of the electronic device, the compilation of the remaining uncompiled hot compilation units may be suspended.
  • the installation process of the application program takes the installation process of the application program as an example. If in the installation phase including the pre-compilation process of the hot-spot compilation unit, it is configured to perform the installation operation of the application first, and then perform the pre-compilation operation of the hot-spot compilation unit, and after the pre-compilation of the hot-spot compilation unit is finished, it is determined that the installation phase is over. In this case, the length of the compilation time of the hotspot compilation unit directly affects the length of the installation phase of the application, and when it is detected that the operating state of the electronic device is switched to a state that does not meet the specified condition, the suspension is suspended.
  • the remaining uncompiled hotspot compilation units are compiled, and the electronic device will determine that the installation phase of the application program is over, so as to avoid the compilation operation of the hotspot compilation unit extending the duration of the installation phase of the application program.
  • the electronic device may send a prompt message when determining that the installation phase of the application program is over.
  • the prompt content may include the completion of the application program installation, so that the user can perceive that the application program has been installed.
  • Step S260 In the suspended state, when it is detected that the electronic device satisfies the recovery condition, resume the compilation of the uncompiled hotspot compilation unit.
  • the electronic device has determined that the application program has completed the installation of the application program, but the hot compilation unit in the configuration file corresponding to the application program has not yet been fully compiled, so , The operating efficiency of the application has not yet been fully optimized.
  • the electronic device can periodically detect whether the electronic device meets the recovery condition. If it is detected that the electronic device satisfies the restoration condition, the compilation of the uncompiled hotspot compilation unit is resumed.
  • the restoration condition may be consistent with the content of the aforementioned specified condition.
  • the recovery condition may include that the electronic device is in an off-screen state, the electronic device is in an idle state, or in a charging state.
  • the application program may include multiple function modules, and each function module may include multiple hotspot compilation units. Then, if the function module is to be optimized for operation, the multiple hotspot compilation units included in the function module need to be pre-compiled.
  • the application program A includes a function module A, a function module B, and a function module C.
  • the configuration file corresponding to the application A includes at least a hotspot compilation unit a, a hotspot compilation unit b, a hotspot compilation unit c, a hotspot compilation unit d, a hotspot compilation unit e, and a hotspot compilation unit f.
  • the hotspot compilation unit a, the hotspot compilation unit b, the hotspot compilation unit c, and the hotspot compilation unit d belong to the functional module A. Then in this case, the hotspot compilation unit a, the hotspot compilation unit b, the hotspot compilation unit c, and the hotspot compilation unit Unit d needs to be pre-compiled in advance, so that the operating efficiency of functional module A can be maximized.
  • the step of suspending the compilation of the remaining uncompiled hotspot compilation units includes: if the electronic device is detected When the running state of is switched to a state that does not meet the specified conditions, after continuing to complete the compilation operation of the currently compiled hotspot compilation unit, the compilation of the remaining uncompiled hotspot compilation units is suspended.
  • the electronic device detects that the running state is switched to not If the specified conditions are met, then in this case, the electronic device will continue to complete the compilation of the remaining code in the hotspot compilation unit b, and then suspend the remaining uncompiled hotspot compilation unit c, hotspot compilation unit d, and hotspot compilation unit e and the hotspot compilation unit f are compiled.
  • the step of compiling by the compiling unit includes: if it is detected that the operating state of the electronic device is switched to a state that does not meet the specified condition, detecting the functional module to which the hotspot compiling unit currently being compiled belongs; if the functional module belongs to the specified After continuing to complete the compilation operation of the currently compiled hotspot compilation unit, the compilation of the remaining uncompiled hotspot compilation units is suspended.
  • function module A is a commonly used function module for configuration
  • function module B and function module C are unusual function modules.
  • the hot compilation unit currently being compiled is hot compilation unit b
  • the hot compilation unit e or the hot compilation unit f the compilation of all the remaining uncompiled content will be suspended. All the remaining uncompiled content includes the remaining uncompiled content of the hot compilation unit currently being compiled, and the remaining hot compilation units that have not yet started to compile.
  • step S240 and step S250 can also be performed in parallel.
  • This application provides a method for pre-compilation of an application, which detects the running state of an electronic device during the installation of the application, so that the pre-compilation operation of the hotspot compilation unit in the configuration file is performed only when the running state meets the specified conditions , So that the compilation timing of the hotspot compilation unit is configurable, instead of directly compiling the hotspot compilation unit at the application installation stage, which will affect the running performance of the electronic device.
  • the operating state of the electronic device in the process of pre-compiling the hotspot compilation unit, the operating state of the electronic device is still continuously detected, and then the operating state of the electronic device is detected to switch to not satisfying the specified In the conditional state, the compilation of the remaining uncompiled hotspot compilation units is suspended, and in the suspended state, when it is detected that the electronic device satisfies the recovery condition, the compilation of the uncompiled hotspot compilation unit is resumed, thereby A more flexible way to compile hot codes is realized.
  • a method for pre-compiling an application program provided by the present application is applied to an electronic device, and the method includes:
  • Step S310 Detect the current operating state of the electronic device.
  • Step S320 If the running state meets the specified condition and the application is in the installation phase, it is detected whether the application is a pre-configured application;
  • Step S330 If it does not belong to the pre-configured application program, the process ends.
  • Step S340 If it belongs to the pre-configured application, obtain a configuration file corresponding to the application, and the configuration file stores a hotspot compilation unit corresponding to the application.
  • Step S341 Perform pre-compilation on the hotspot coding unit.
  • Step S350 If the operating state does not meet the specified condition, periodically check whether the electronic device meets the specified condition, until it is detected that the electronic device meets the specified condition, and pre-compile the hotspot compilation unit .
  • the configuration file corresponding to the application program acquired by the electronic device in the embodiment of the present application may be a server (for example, the server 200 in FIG. 1 or the server 201 in FIG. 3) based on multiple collected
  • the second configuration file is used to obtain the hotspot compilation unit included in the configuration file corresponding to the application obtained by the electronic device in the embodiment of the present application.
  • the server may obtain multiple second configuration files corresponding to the target application from multiple electronic devices, and the second configuration file is used to record the hotspot compilation unit of the target application.
  • Each application program can be configured with a profile file (profile file) during its operation.
  • the configuration file is used to record the hotspot compilation unit of the application in the running process.
  • an application program A, an application program B, and an application program C are installed in the electronic device.
  • the application A can correspond to a configuration file a
  • the application B can correspond to a configuration file b
  • the application C can correspond to a configuration file c.
  • the hotspot compilation unit of application A is recorded in configuration file a
  • the hotspot compilation unit of application B is recorded in configuration file b
  • the hotspot compilation unit of application C is recorded in configuration file c.
  • the application programs installed for different electronic devices may be different or the same.
  • application A, application B, and application C may be installed on multiple electronic devices.
  • the target application program is an application program to which the configuration file to which it belongs will be processed in subsequent steps.
  • the server may determine the target application program in multiple ways.
  • the server can use the application with a large amount of installation as the target application.
  • the electronic device may periodically upload application program installation information to the server, and the application program installation information includes applications currently installed by the electronic device. Then, the server can perform statistics on the application installation information uploaded by multiple electronic devices on a regular basis, and if it is detected that the installation amount of a certain application is greater than the installation threshold, the application with the installation amount greater than the installation threshold can be used as the target application.
  • the server can upload application A As the target application. In this way, the server can optimize the operating efficiency of the installed application program in a timely manner.
  • the electronic device can simultaneously determine the target application in combination with the amount of installation and the size of the corresponding configuration file. It should be noted that because different applications have different functions or operating frequencies, the size of their configuration files is different, and the electronic device compiles the hotspot compilation unit in the configuration file before the application runs. If a certain amount of resources and time needs to be consumed, then for applications with smaller configuration files, it can be determined that the running frequency may be lower, and the server may not process the configuration files to which these lower running frequency applications belong. Correspondingly, in this manner, in the application installation information reported by the electronic device, in addition to the installed applications, the size of the configuration file to which each application belongs may also be included. When the server detects that among multiple electronic devices, the size of the configuration file to which a certain application belongs is greater than the specified threshold and the number is greater than the threshold, the same application can be used as the target application.
  • each of the 90 electronic devices has one application A installed Configuration files (that can be understood as 90 configuration files). If the server recognizes that 80 of its 90 configuration files are less than 1kb, then when the installation threshold is 80, the specified threshold is 10kb, and the number of thresholds is 50, the server will not use application A as the target application . However, if the server recognizes that 60 of the 90 configuration files (greater than the threshold number of 50) have a size of 11-12 kb (greater than the specified threshold of 10 kb), then the application A can be determined as the target application.
  • the server can also determine the target application according to the configuration information. In this way, you can determine which applications are the target applications through manual configuration.
  • the server may use the application involved in the application installation information reported by multiple electronic devices as the candidate application, and the operator may select one or more applications from the candidate application as the selected application.
  • the application program correspondingly, the server stores the selected application program in the configuration file. In this case, the server can use the application program configured in the configuration file as the target application program.
  • the server may further use the configuration file to which the target application belongs as the second configuration file.
  • the multiple second configuration files corresponding to the target application can be understood as the configuration files to which the same target application installed in multiple electronic devices belongs.
  • the server may directly de-duplicate all the hotspot compilation units in the multiple second configuration files as the obtained multiple hotspot compilation units.
  • This application provides a method for pre-compilation of an application, which detects the operating state of an electronic device during the installation phase of the application when the application belongs to a pre-configured application, so that only when the operating state meets the specified conditions Only then will the pre-compilation operation of the hotspot compilation unit in the configuration file be performed, so that the compilation timing of the hotspot compilation unit is configurable, instead of directly compiling the hotspot compilation unit during the application installation phase, causing the operation of the electronic device Performance is affected.
  • a device 400 for pre-compiling an application program provided by the present application runs on an electronic device, and the device 400 includes:
  • the state detection unit 410 is configured to detect the current operating state of the electronic device.
  • the installation phase includes an installation package installation phase of the application program or an update file installation phase of the application program.
  • the information obtaining unit 420 is configured to obtain a configuration file corresponding to the application program if the running state meets the specified condition and the application program is in the installation stage, and the configuration file stores a hotspot compilation unit corresponding to the application program .
  • the information obtaining unit 420 is further configured to obtain a configuration file corresponding to the application program if the running state meets a specified condition and the configuration file of the application program is not pre-compiled during the installation phase.
  • the specified condition includes: the electronic device is in an off-screen state; if the application is not in the installation phase, the specified condition includes: the power of the electronic device At least one of meeting the specified power threshold, the available storage space of the electronic device is not less than the specified space threshold, and the temperature of the electronic device is not higher than the specified temperature threshold.
  • the compiling unit 430 is configured to precompile the hotspot compiling unit.
  • the compiling unit 430 is further configured to suspend the compiling if it is detected that the operating state of the electronic device is switched to a state that does not meet the specified condition during the pre-compiling of the hotspot compiling unit.
  • the remaining uncompiled hotspot compiling units are compiled; in the suspended state, when it is detected that the electronic device meets the recovery condition, the uncompiled hotspot compiling unit is resumed to compile.
  • the compiling unit 430 is specifically configured to, if it is detected that the operating state of the electronic device is switched to a state that does not meet the specified condition, after continuing to complete the compiling operation of the currently compiled hotspot compiling unit, Suspend the compilation of the remaining uncompiled hot compilation units.
  • the compiling unit 430 is specifically configured to detect the function module of the hotspot compiling unit currently being compiled if it is detected that the operating state of the electronic device is switched to a state that does not meet the specified condition; The function module belongs to the designated common function module. After the compilation operation of the currently compiled hotspot compilation unit continues to be completed, the compilation of the remaining uncompiled hotspot compilation units is suspended.
  • the restoration condition includes: the electronic device is in a screen off state; the electronic device is in a charging state; or the electronic device is in a processing idle state.
  • the state detection unit 410 specifically includes:
  • the application program detection subunit 411 is configured to detect whether the application program belongs to a pre-configured application program when the application program is in the installation stage;
  • the state detection subunit 412 is configured to detect the current operating state of the electronic device if it belongs to the pre-configured application.
  • an embodiment of the present application also provides another electronic device 200 that can execute the above-mentioned method for pre-compiling an application.
  • the electronic device 200 includes one or more (only one is shown in the figure) processor 102, a memory 104, and a network module 106 that are coupled to each other.
  • the memory 104 stores a program that can execute the content in the foregoing embodiment, and the processor 102 can execute the program stored in the memory 104.
  • the processor 102 may include one or more processing cores.
  • the processor 102 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes by running or executing instructions, programs, code sets, or instruction sets stored in the memory 104, and calling data stored in the memory 104.
  • the processor 102 may use at least one of digital signal processing (Digital Signal Processing, DSP), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA), and Programmable Logic Array (Programmable Logic Array, PLA).
  • DSP Digital Signal Processing
  • FPGA Field-Programmable Gate Array
  • PLA Programmable Logic Array
  • the processor 102 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), a modem, and the like.
  • the CPU mainly processes the operating system, user interface, and application programs; the GPU is used for rendering and drawing of display content; the modem is used for processing wireless communication. It is understandable that the above-mentioned modem may not be integrated into the processor 102, but may be implemented by a communication chip alone.
  • the memory 104 may include random access memory (RAM) or read-only memory (Read-Only Memory).
  • the memory 104 may store a device for pre-compilation of application programs.
  • the device for pre-compiling the application program may be the aforementioned device 400.
  • the memory 104 may be used to store instructions, programs, codes, code sets or instruction sets.
  • the memory 104 may include a storage program area and a storage data area, where the storage program area may store instructions for implementing the operating system and instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.) , Instructions used to implement the following various method embodiments, etc.
  • the data storage area can also store data (such as phone book, audio and video data, chat record data) created by the terminal 100 during use.
  • the network module 106 is used to receive and send electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, so as to communicate with a communication network or other equipment, such as communication with a wireless access point.
  • the network module 106 may include various existing circuit elements for performing these functions, for example, an antenna, a radio frequency transceiver, a digital signal processor, an encryption/decryption chip, a subscriber identity module (SIM) card, a memory, etc. .
  • SIM subscriber identity module
  • the network module 106 can also be used as a network adapter for the electronic device 200 to directly connect to the network through a line connection.
  • the network may include a cellular telephone network, a wireless local area network, or a metropolitan area network.
  • FIG. 11 shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application.
  • the computer-readable medium 800 stores program code, and the program code can be invoked by a processor to execute the method described in the foregoing method embodiment.
  • the computer-readable storage medium 800 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
  • the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium.
  • the computer-readable storage medium 800 has storage space for the program code 810 for executing any method steps in the above-mentioned methods. These program codes can be read from or written into one or more computer program products.
  • the program code 810 may be compressed in a suitable form, for example.
  • the method, device, electronic device, and storage medium for pre-compilation of an application program provided by this application are obtained when it is detected that the operating state of the electronic device meets the specified conditions and the application program is in the installation stage.
  • the configuration file of the hotspot compilation unit corresponding to the application is stored corresponding to the application, and the hotspot compilation unit is pre-compiled. Therefore, the method of detecting the running status of the electronic device makes the pre-compilation operation of the hotspot compilation unit in the configuration file only when the running status meets the specified conditions, so that the compilation timing of the hotspot compilation unit is configurable, instead of directly During the application installation stage, the hotspot compilation unit is directly compiled, which affects the running performance of the electronic device.

Abstract

一种应用程序预编译的方法、装置、电子设备及存储介质,所述方法包括:当处于应用程序的安装阶段时,检测所述电子设备当前的运行状态;若所述运行状态满足指定条件,获取所述应用程序对应的配置文件,所述配置文件中存储有所述应用程序对应的热点编译单元;对所述热点编译单元进行预编译。所述方法只有在运行状态满足指定条件时才会进行配置文件中的热点编译单元的预编译操作,使得热点编译单元的编译时机具有可配置性,不会造成电子设备的运行性能受到影响。

Description

应用程序预编译的方法、装置、电子设备及存储介质
相关申请的交叉引用
本申请要求于2019年12月24日提交的申请号为201911349773.X的中国申请的优先权,其在此出于所有目的通过引用将其全部内容并入本文。
技术领域
本申请涉计算机技术领域,更具体地,涉及一种应用程序预编译的方法、装置、电子设备及存储介质。
背景技术
在电子设备中,可以通过提前编译的方式来实现一定程度的提升应用程序的运行效率。但是,相关的编译方式会造成电子设备的运行性能受到影响,降低了用户体验。
发明内容
鉴于上述问题,本申请提出了一种应用程序预编译的方法、装置、电子设备及存储介质,以改善上述问题。
第一方面,本申请提供了一种应用程序预编译的方法,应用于电子设备,所述方法包括:检测所述电子设备当前的运行状态;若所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的配置文件,所述配置文件中存储有所述应用程序对应的热点编译单元;对所述热点编译单元进行预编译。
第二方面,本申请提供了一种应用程序预编译的装置,运行于电子设备,所述装置包括:状态检测单元,用于检测所述电子设备当前的运行状态;信息获取单元,用于若所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的配置文件,所述配置文件中存储有所述应用程序对应的热点编译单元;编译单元,用于对所述热点编译单元进行预编译。
第三方面,本申请提供了一种电子设备,包括一个或多个处理器以及存储器;一个或多个程序,其中所述一个或多个程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行上述的方法。
第四方面,本申请提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有程序代码,其中,在所述程序代码运行时执行上述的方法。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本 申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出了本申请实施例提出的一种应用程序预编译的方法的运行环境示意图。
图2示出了本申请实施例提出的另一种应用程序预编译的方法的运行环境示意图。
图3示出了本申请实施例提出的再一种应用程序预编译的方法的运行环境示意图。
图4示出了本申请实施例提出的一种应用程序预编译的方法的流程图。
图5示出了本申请另一实施例提出的一种应用程序预编译的方法的流程图。
图6示出了本申请再一实施例提出的一种应用程序预编译的方法的流程图。
图7示出了本申请又一实施例提出的一种应用程序预编译的方法的流程图。
图8示出了本申请提出的一种应用程序预编译的装置的结构框图。
图9示出了本申请提出的另一种应用程序预编译的装置的结构框图。
图10示出了本申请的用于执行根据本申请实施例的应用程序预编译的方法的电子设备的结构框图。
图11是本申请实施例的用于保存或者携带实现根据本申请实施例的应用程序预编译的方法的程序代码的存储单元。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
随着电子设备中应用程序的运行方式的发展,电子设备中的应用程序可以在运行时先通过解析器(Interpreter)直接解析执行,执行过程中记录每个编译单元的调用次数和循环次数,当调用次数和循环次数超过设定阈值,则对应的编译单元被记录为热点编译单元。其中,编译单元可以理解为应用程序的源码中的函数、方法(method)或者类(class)。进一步的,热点编译单元会被识别并被JIT(Just In Time,即时编译)编译后存储并生成profile文件以记录热点编译单元的信息。在这种情况下,电子设备的系统会扫描profile文件并执行AOT(Ahead Of Time,预编译)过程进行编译。
但是,发明人在对该方式进行研究中发现,在相关的profile文件运行以进行热点编译单元的编译过程中,都是固定在一个时间段进行的,这样就会造成电子设备即使已经在处理资源较为紧张的状态下,依然需要消耗更多的处理资源进行热点编译单元的编译,进而造成电子设备的运行性能下降。例如,在电子设备安装应用程序的过程中,可能会伴随应用程序的安装包同时 下载有应用程序对应的热点编译单元,而若该应用程序本身的安装包较大的情况下,就需要消耗较多电子设备的处理资源进行安装包的安装,但是若依然在安装阶段进行热点编译单元的预编译操作,那么就可能会造成安装包的安装过程延长,造成用户体验下降。
因此,提出了申请提供的应用程序预编译的方法、装置、电子设备及存储介质,当处于应用程序的安装阶段时,检测所述电子设备当前的运行状态,若所述运行状态满足指定条件,获取所述应用程序对应的存储有所述应用程序对应的热点编译单元的配置文件,对所述热点编译单元进行预编译。从而通过在应用程序安装阶段检测电子设备的运行状态的方式,使得只有在运行状态满足指定条件才会进行配置文件中的热点编译单元的预编译操作,使得热点编译单元的编译时机具有可配置性,而不会直接在应用程序安装阶段就直接对热点编译单元进行编译造成电子设备的运行性能受到影响。
下面先对本申请实施例所涉及的一种场景进行介绍。
请参阅图1,在图1所涉及的场景中,包括有多个电子设备100以及服务器200。其中,多个电子设备100通过网络与服务器200进行数据交互。
在多个电子设备100中都运行有目标应用程序,而每个电子设备100所运行的目标应用程序都对应生成有配置文件(可以为前述的profile文件)120。在一种方式下,多个电子设备100可以将自己安装的目标应用程序的配置文件120上传到服务器200中,以便服务器可以得到目标应用程序对应的多个配置文件120,进而对该多个配置文件120进行融合处理,提取该多个配置文件120所包括的多个热点编译单元,然后得到包括该多个热点编译单元的配置文件210,再将配置文件210分别返回给该多个电子设备100。其中,该多个热点编译单元可以为多个配置文件120去重后的热点编译单元,也可以为多个配置文件120中所有的热点编译单元中编译次数超过阈值的热点编译单元,还可以为指定功能模块对应的热点编译单元。
此外,如图2所示,还可以由服务器200直接将该配置文件210以及目标应用程序的安装程序220的程序安装包230发送给还未安装目标应用程序的电子设备130,以便可以使得电子设备130在安装目标应用程序时,就可以运行配置文件210,以进行部分热点编译单元的预编译。示例性的,电子设备130还可以根据当前的运行状态来确定配置文件210的运行时机。
需要说明的是,在图2所示的环境中,进行收集多个配置文件120并对该多个配置文件120进行处理得到配置文件210的服务器可以为单个服务器,也可以为服务器集群。并且,进行收集多个配置文件120并对该多个配置文件120进行处理得到配置文件210的服务器可以和后续下发程序安装包230的服务器为不同的服务器。例如,如图3所示,在图3所示的情况下,服务器200只用于执行前述的收集多个电子设备100上传的配置文件,然后将所收集到的配置文件再发送给服务器201,然后由服务器201来执行提取该多个配置文件120所包括的多个热点编译单元,然后基于该多个热点编译单元得到配置文件210,再将配置文件210分别返回给该多个电子设备100。此外,服务器201也可以将生成的配置文件210发送给服务器200,进而由服务器 200来转发给多个电子设备100(图中未示出)。其中,需要说明的是,服务器201中可以直接运行有应用分发平台,在这种情况下,服务器201可以直接将配置文件210配置在程序安装包230中发送给还未安装目标应用程序的电子设备130。而若应用分发平台独立运行的情况下,可以由服务器201将配置文件210发送给应用分发平台,以便应用分发平台将配置文件210配置在程序安装包230中发送给还未安装目标应用程序的电子设备130。
再者,在后续实施例中所提及的配置文件可以为配置文件210。其中,新生成的配置文件210中的热点编译单元可以为服务器200编译后的热点编译单元,也可以为还未运行编译的热点编译单元。在新生成的配置文件210中的热点编译单元为还未运行编译的热点编译单元的情况下,可以由接收到新生成的配置文件210的电子设备在运行目标应用程序之前进行编译,或者在安装目标应用程序时就进行编译。而为服务器200编译后的热点编译单元的情况下,可以为服务器200基于所要分发的电子设备的硬件环境进行编译后的热点编译单元。
下面将结合具体实施例对本申请内容进行介绍。
请参阅图4,本申请提供的一种应用程序预编译的方法,应用于电子设备,所述方法包括:
步骤S110:检测所述电子设备当前的运行状态。
需要说明的是,在本实施例中,电子设备在从服务器获取应用程序的安装文件时,所获取的安装文件中除了应用程序本身的安装程序外,还可以携带有应用程序对应的配置文件,该配置文件可以为前述介绍内容中的配置文件210。
此外,作为另外一种方式,应用程序所对应存储的热点编译单元还可以存储在其他区域(即未存储应用程序安装包的服务器中),那么在这种情况下,电子设备在向存储有安装文件的服务器发起安装文件请求时,该存储有安装文件的服务器可以向电子设备返回一指向存储有配置文件的服务器的重定向信息,以便电子设备同时会向该存储有配置文件的服务器发起配置文件请求。那么在这种情况下,作为一种方式,电子设备可以在接收到安装文件以及配置文件后再触发进入应用程序的安装阶段,以便电子设备可以在运行安装文件的过程中就可以实现预编译热点编译单元。
其中,电子设备的运行状态可以包括多种状态。
作为一种方式,电子设备的运行状态可以包括硬件状态。可以理解的是,电子设备在运行过程中其所包括的处理器(CPU)、图形处理器(GPU)以及存储器等硬件设备都会处于运行状态,以完成电子设备运行过程中的数据处理以及数据读写操作。而若电子设备的硬件设备处于较高频率的运行状态下,可能会影响电子设备的运行效率。示例性的,若该安装过程为应用程序的安装过程,电子设备会进行安装包的解压以及对应的目录的创建,甚至还包括对安装包解压得到的文件的处理过程。而若在这个过程中,过度的占用处理器的处理资源,那么就会造成应用程序的安装过程被延长。而若在应用程序的安装过程中,处理器即使处于应用程序的安装过程中依然还剩余有较多的 处理资源,那么即使再进行其他的数据处理操作,可能对应用程序的安装过程影响较小。那么在这种情况下,运行状态可以包括处理器的剩余处理资源,若检测到剩余处理资源不小于指定资源阈值,则表征运行状态满足指定条件。从而通过这种方式,可以在安装阶段检测到剩余处理资源不小于指定资源阈值的情况下,才进行热点编译单元的编译操作,以免影响电子设备的运行性能。
作为另一种方式,电子设备的运行状态可以包括硬件器件的状态。可以理解的是,电子设备可以包括有屏幕以及传感器等硬件器件。而硬件器件处于不同的运动状态可能会表征用户不同的使用状态。例如,若传感器包括有配置在前置摄像头附近的距离传感器,且该距离传感器检测到距离值小于指定距离阈值,则表征用户当前处于接听电话的状态。再例如,若屏幕当前处于息屏状态,则可以表征用户当前并未关注电子设备。那么在这种情况下,电子设备的运行状态可以包括屏幕的运行状态,若处于息屏状态,则判定运行状态满足指定条件,而若电子设备处于亮屏状态,则判定不满足指定条件。从而通过检测屏幕的运行状态的方式,可以在用户不关注电子设备的情况下进行热点编译单元的预编译操作,以便减少热点编译单元的预编译操作对用户使用电子设备造成干扰。
作为再一种方式,电子设备的运行状态可以包括软件状态。需要说明的是,电子设备可以同时运行多个应用程序,而当前处于运行状态的应用程序的数量越多,那么电子设备再执行另外的数据处理任务的速率就会更慢。在这种方式下,电子设备的运行状态可以包括当前处于运行状态的应用程序的数量。
再者,电子设备的运行状态可以包括前述多种方式中的一个或多个。需要说明的是,在一些情况下,单纯通过一种前述的运行状态判断方式,无法较为准确的判断电子设备的当前运行状态。示例性的,电子设备中的一些应用程序可以在后台运行,甚至是在息屏状态下运行,那么若电子设备检测到当前处于息屏状态,就直接判定电子设备的运行状态满足指定条件,但是当前处于后台运行的应用程序本身又会占用较多的数据处理资源的情况下,就可能会使得电子设备进行热点编译单元的编译过程进一步造成电子设备的性能下降。例如,电子设备检测到当前处于息屏状态,但是处理器剩余的处理资源为10%的处理资源,那么若电子设备单独因为电子设备处于息屏状态就判定电子设备的运行状态满足指定条件,那么就会触发进行后续的热点编译单元的编译操作,进而会造成处理器的剩余处理资源降低到更低,势必会影响电子设备在息屏状态下所进行的其他数据处理操作。
那么为了改善上述问题,作为一种方式,电子设备的运行状态可以包括硬件器件的运行状态以及硬件状态。可选的,电子设备可以在检测到当前处于息屏状态,且剩余处理资源不低于指定阈值的情况下,判定电子设备的运行状态满足指定条件。其中,可选的,该指定阈值低于前述的指定资源阈值。需要说明的是,在电子设备处于息屏状态下,用户较大概率并未关注电子设备的运行状态,那么在这种情况下可以不用严苛的限定剩余处理资源,即在 同时对硬件器件的运行状态以及硬件状态进行判定的情况下的指定阈值,可以低于单独以硬件状态作为判断依据的情况下的指定资源阈值。
作为另一种方式,电子设备可以根据是否处于应用程序安装来配置指定条件的内容。可选的,若在应用程序处于安装阶段时,所述指定条件包括:所述电子设备处于灭屏状态;若在应用程序不处于安装阶段时,所述指定条件包括:所述电子设备的电量满足指定电量阈值、所述电子设备的可用存储空间不小于指定空间阈值以及所述电子设备的温度不高于指定温度阈值中的至少一个。
步骤S120:若所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的配置文件,所述配置文件中存储有所述应用程序对应的热点编译单元。
需要说明的是,在本申请实施例中,安装阶段可以理解为应用程序的安装阶段,也可以理解为应用程序的更新文件的安装阶段。
需要说明的是,若电子设备检测到运行状态满足指定条件,则表征电子设备当前即使同时进行热点编译单元的预编译操作,也不会使得电子设备剩余的处理资源过紧而造成电子设备的运行性能受到影响,或者是表征电子设备当前即使同时进行热点编译单元的预编译操作,造成了电子设备剩余的处理资源过紧,但是因为用户处于未关注电子设备的状态,对于用户而言也不会感知到剩余的处理资源过紧而造成电子设备的运行性能受到影响。
步骤S121:对所述热点编译单元进行预编译。
需要说明的是,作为一种方式,电子设备在步骤S120中所获取到的配置文件为还未进行编译的配置文件,即可以理解为dex文件。而在本实施例中对于配置文件的预编译的操作可以理解为进行AOT编译,即将dex格式的配置文件经过预编译后转换为oat或者odex格式的文件。
步骤S130:若所述运行状态不满足指定条件,周期性检测所述电子设备是否满足所述指定条件,直到检测到所述电子设备满足所述指定条件,且对所述热点编译单元进行预编译。
需要说明的是,若在安装阶段检测到运行状态不满足指定条件,那么为了不影响电子设备当前的运行状态,可以选择在后续的运行过程中进行预编译的操作。进而就可以周期性的,检测所述电子设备是否满足所述指定条件。例如,可以每天的在固定时间段检测一次是否满足所述指定条件。其中,当电子设备完成对配置文件的热点编译单元的编译后,就可以停止周期性检测所述电子设备是否满足所述指定条件。
本申请提供的一种应用程序预编译的方法,当检测所述电子设备的所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的存储有所述应用程序对应的热点编译单元的配置文件,对所述热点编译单元进行预编译。从而通过检测电子设备的运行状态的方式,使得只有在运行状态满足指定条件才会进行配置文件中的热点编译单元的预编译操作,使得热点编译单元的编译时机具有可配置性,而不会直接在应用程序安装阶段就直接对热点编译单元进行编译造成电子设备的运行性能受到影响。
请参阅图5,本申请提供的一种应用程序预编译的方法,应用于电子设备,所述方法包括:
步骤S201:检测所述电子设备当前的运行状态。
步骤S202:若所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的配置文件,所述配置文件中存储有所述应用程序对应的热点编译单元。
步骤S203:对所述热点编译单元进行预编译。
步骤S204:若所述运行状态不满足指定条件,且应用程序处于安装阶段时,不对所述热点编译单元进行预编译。
步骤S205:若所述运行状态满足指定条件,且所述应用程序的配置文件在所述安装阶段未进行预编译,获取所述应用程序对应的配置文件。
步骤S206:对所述热点编译单元进行预编译。
作为一种方式,在对所述热点编译单元进行预编译的过程中,若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,继续完成对所述应用程序的配置文件中剩余未编译的热点编译单元进行编译;暂停编译排序在所述应用程序之后进行编译的应用程序的配置文件;在所述暂停状态下,检测到所述电子设备满足所述指定条件时,恢复对所述在所述应用程序之后进行编译的应用程序的配置文件进行编译。
本申请提供的一种应用程序预编译的方法,通过检测电子设备的运行状态的方式,使得只有在运行状态满足指定条件才会进行配置文件中的热点编译单元的预编译操作,使得热点编译单元的编译时机具有可配置性,而不会直接在应用程序安装阶段就直接对热点编译单元进行编译造成电子设备的运行性能受到影响。并且在本实施例中,可以在编译过程中检测到电子设备的运行状态切换为不满足指定条件的情况下,及时的暂停后续的应用程序的配置文件的预编译操作,进而及时的避免编译操作造成对用户的干扰。
请参阅图6,本申请提供的一种应用程序预编译的方法,应用于电子设备,所述方法包括:
步骤S210:当检测所述电子设备当前的运行状态。
步骤S220:若所述运行状态不满足指定条件,周期性检测所述电子设备是否满足所述指定条件,直到检测到所述电子设备满足所述指定条件,且对所述热点编译单元进行预编译。
步骤S230:若所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的配置文件,所述配置文件中存储有所述应用程序对应的热点编译单元。
步骤S240:对所述热点编译单元进行预编译。
步骤S250:在对所述热点编译单元进行预编译的过程中,若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,暂停对剩余未编译的热点编译单元进行编译。
需要说明的是,电子设备的运行状态是有可能会突然变化的,那么虽然是因为电子设备运行状态满足指定条件而触发对配置文件中的热点编译单元 进行编译操作。但是,电子设备在进行预编译的过程中,电子设备的运行状态可能会转变为不满足指定条件。那么在这种情况下,为了避免预编译操作对用户使用电子设备造成影响,进而可以暂停对剩余未编译的热点编译单元进行编译。
示例性的,以应用程序的安装过程为例。若在包括热点编译单元预编译过程的安装阶段中,配置为先进行应用程序的安装操作,然后再进行热点编译单元预编译操作,而在热点编译单元预编译结束后,才判定安装阶段结束。那么在这种情况下,热点编译单元的编译时间长度就直接影响了应用程序的安装阶段的长度,进而在检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,暂停对剩余未编译的热点编译单元进行编译,并且电子设备会判定应用程序的安装阶段结束,以避免热点编译单元的编译操作延长应用程序的安装阶段的时长。其中,电子设备在判定应用程序的安装阶段结束时,可以发出提示信息,例如,提示内容可以包括应用程序安装完成,以便用户可以感知到应用程序已经完成安装。
步骤S260:在所述暂停状态下,检测到所述电子设备满足恢复条件时,恢复对所述未编译的热点编译单元进行编译。
需要说明的是,虽然作为一种方式,在暂停状态下,电子设备已经判定应用程序完成了应用程序的安装,但是,该应用程序对应的配置文件中的热编译单元还未完全进行编译,因此,应用程序的运行效率还未完全得到优化。那么为了实现最大程度优化运行效率,电子设备可以周期性的检测到所述电子设备是否满足恢复条件。若检测到所述电子设备满足恢复条件时,恢复对所述未编译的热点编译单元进行编译。
可选的,该恢复条件可以与前述的指定条件的内容一致。可选的,该恢复条件可以包括所述电子设备处于灭屏状态、电子设备处于空闲状态或者处于充电状态。
可以理解的是,应用程序可以包括有多个功能模块,而每个功能模块可以包括有多个热点编译单元。那么如果要达到对该功能模块的运行优化,那么该功能模块所包括的多个热点编译单元都需要进行预编译。示例性的,应用程序A包括功能模块A、功能模块B以及功能模块C。其中,应用程序A对应的配置文件中至少包括热点编译单元a、热点编译单元b、热点编译单元c、热点编译单元d、热点编译单元e以及热点编译单元f。其中,热点编译单元a、热点编译单元b、热点编译单元c、热点编译单元d属于功能模块A,那么在这种情况下,热点编译单元a、热点编译单元b、热点编译单元c、热点编译单元d都需要提前进行预编译,功能模块A对应的运行效率才能得到最大程度的提升。
那么作为一种方式,若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,暂停对剩余未编译的热点编译单元进行编译的步骤包括:若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,在继续完成当前所编译的热点编译单元的编译操作后,暂停对剩余未编译的热点编译单元进行编译。
继续以前述内容为例,若电子设备当前所编译的热点编译单元为热点编译单元b,但是只完成了热点编译单元b中一半代码的预编译操作时,电子设备就检测到运行状态切换为不满足所述指定条件的状态,那么在这种情况下,电子设备会继续完成热点编译单元b中剩余代码的编译后,暂停对剩余未编译的热点编译单元c、热点编译单元d、热点编译单元e以及热点编译单元f进行编译。
其中,可选的,若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,在继续完成当前所编译的热点编译单元的编译操作后,暂停对剩余未编译的热点编译单元进行编译的步骤包括:若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,检测当前正在编译的热点编译单元所属的功能模块;若所述功能模块属于指定的常用功能模块,在继续完成当前所编译的热点编译单元的编译操作后,暂停对剩余未编译的热点编译单元进行编译。
继续以前述内容为例,在应用程序A包括的功能模块A、功能模块B以及功能模块C中,功能模块A为配置的常用功能模块,功能模块B以及功能模块C为非常用功能模块。那么在这种情况下,若检测当前正在编译的热点编译单元为热点编译单元b,那么就可以在继续完成当前所编译的热点编译单元的编译操作后,暂停对剩余未编译的热点编译单元进行编译。而若当前正在编译的热点编译单元为热点编译单元e或者热点编译单元f,那么就会暂停编译所有的剩余未编译的内容。该所有的剩余未编译的内容包括当前正在编译的热点编译单元剩余的未编译内容,以及剩余的还未开始编译的热点编译单元。
需要说明的是前述步骤S240和步骤S250也可以并行进行。
本申请提供的一种应用程序预编译的方法,通过在应用程序安装阶段检测电子设备的运行状态的方式,使得只有在运行状态满足指定条件才会进行配置文件中的热点编译单元的预编译操作,使得热点编译单元的编译时机具有可配置性,而不会直接在应用程序安装阶段就直接对热点编译单元进行编译造成电子设备的运行性能受到影响。并且,在本实施例中,在对所述热点编译单元进行预编译的过程中,依然会持续检测电子设备的运行状态,进而在检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,暂停对剩余未编译的热点编译单元进行编译,并且在所述暂停状态下,检测到所述电子设备满足恢复条件时,恢复对所述未编译的热点编译单元进行编译,从而实现了更加灵活的热点代码编译方式。
请参阅图7,本申请提供的一种应用程序预编译的方法,应用于电子设备,所述方法包括:
步骤S310:检测所述电子设备当前的运行状态。
步骤S320:若所述运行状态满足指定条件,且应用程序处于安装阶段时,检测所述应用程序是否属于预配置的应用程序;
步骤S330:若不属于所述预配置的应用程序,结束流程。
步骤S340:若属于所述预配置的应用程序,获取所述应用程序对应的配 置文件,所述配置文件中存储有所述应用程序对应的热点编译单元。
步骤S341:对所述热点编译单元进行预编译。
步骤S350:若所述运行状态不满足指定条件,周期性检测所述电子设备是否满足所述指定条件,直到检测到所述电子设备满足所述指定条件,且对所述热点编译单元进行预编译。
需要说明的是,在本申请实施例中电子设备所获取的所述应用程序对应的配置文件可以为服务器(例如,图1中的服务器200或者图3中的服务器201)基于收集到的多个第二配置文件来得到本申请实施例中电子设备所获取的所述应用程序对应的配置文件中所包括的热点编译单元。
在这种方式中,服务器可以从多个电子设备中获取目标应用程序对应的多个第二配置文件,所述第二配置文件用于记录所述目标应用程序的热点编译单元。
需要说明的是,电子设备中可以运行有多个应用程序。而每个应用程序在运行过程中都可以配置有一个所属的配置文件(profile文件)。该配置文件用于记录所属应用程序在运行过程中的热点编译单元。示例性的,在电子设备中安装有应用程序A、应用程序B以及应用程序C。那么应用程序A可以对应有一个所属的配置文件a,而应用程序B可以对应有一个所属的配置文件b,应用程序C可以对应有一个所属的配置文件c。那么在这种情况下,配置文件a中记录有应用程序A的热点编译单元,配置文件b中记录有应用程序B的热点编译单元,配置文件c中记录有应用程序C的热点编译单元。其中,对于不同的电子设备所安装的应用程序可以不同,也可以相同。例如,对于多个电子设备可以都安装有应用程序A、应用程序B以及应用程序C。
可以理解的是,目标应用程序为所属的配置文件会进行后续步骤处理的应用程序,在本申请实施例中,服务器可以有多种方式来确定目标应用程序。
作为一种方式,服务器可以将安装量较多的应用程序作为目标应用程序。可选的,电子设备可以定期的向服务器上传应用程序安装信息,在该应用程序安装信息中包括电子设备当前所已经安装的应用程序。那么服务器可以对多个电子设备定期上传应用程序安装信息进行统计,若检测到某个应用程序的安装量大于安装阈值,则可以将该安装量大于安装阈值的应用程序作为目标应用程序。
示例性的,有上传过应用程序安装信息给服务器的电子设备有100个,而其中90个电子设备中都安装有应用程序A,在安装阈值为80的情况下,那么服务器可以将应用程序A作为目标应用程序。通过这种方式,可以使得服务器及时的对安装量较大的应用程序进行运行效率的优化。
作为另外一种方式,电子设备可以同时结合安装量以及对应的配置文件的大小来确定目标应用程序。需要说明的是,不同的应用程序因为自身的功能或者运行频率的不同,所属的配置文件的大小是不同的,而电子设备在应用程序运行前提前进行对配置文件中的热点编译单元进行编译是需要消耗一定的资源以及时间的,那么对于配置文件较小的应用程序,可以确定其运行频率可能较低,服务器就可以不对这些运行频率较低的应用程序所属的配置 文件进行处理。对应的,在这种方式下,电子设备上报的应用程序安装信息中,除了有所安装的应用程序外,还可以包括每个应用程序所属的配置文件的大小。服务器在检测到多个电子设备中,某同一个应用程序所属的配置文件的大小大于指定阈值的数量大于阈值数量时,就可以将该同一个应用程序作为目标应用程序。
示例性的,有上传过应用程序安装信息给服务器的电子设备有100个,而其中90个电子设备中都安装有应用程序A,那么这90个电子设备所安装的应用程序A都各自有一个配置文件(即可以理解为有90个配置文件)。若服务器识别到其90个配置文件中,80个都是小于1kb的,那么在安装阈值为80,指定阈值为10kb,阈值数量为50的情况下,服务器不会将应用程序A作为目标应用程序。但是,若服务器识别到90个配置文件中有60个(大于阈值数量50)配置文件的大小都为11~12kb(大于指定阈值10kb),那么就可以判定该应用程序A为目标应用程序。
作为再一种方式,服务器还可以根据配置信息来确定目标应用程序。在这种方式下,可以通过人为配置的方式来确定哪些应用程序为目标应用程序。示例性的,服务器可以将多个电子设备上报的应用程序安装信息所涉及的应用程序作为待选的应用程序,操作人员可以从该待选的应用程序中选择一个或多个应用程序作为选中的应用程序,对应的,服务器将该选中的应用程序存储在配置文件中,那么在这种情况下,服务器可以将配置到该配置文件中的应用程序作为目标应用程序。
在基于前述方式确定目标应用程序后,服务器可以进一步的将目标应用程序所属的配置文件作为第二配置文件。而在本申请实施例中,目标应用程序对应的多个第二配置文件可以理解为多个电子设备中所安装的同一目标应用程序各自所属的配置文件。
在获取到多个第二配置文件后,作为一种方式,服务器可以直接将多个第二配置文件中的所有热点编译单元去重后作为获取的多个热点编译单元。
本申请提供的一种应用程序预编译的方法,通过在应用程序属于预配置的应用程序的情况下,在该应用程序安装阶段检测电子设备的运行状态的方式,使得只有在运行状态满足指定条件才会进行配置文件中的热点编译单元的预编译操作,使得热点编译单元的编译时机具有可配置性,而不会直接在应用程序安装阶段就直接对热点编译单元进行编译,造成电子设备的运行性能受到影响。
请参阅图8,本申请提供的一种应用程序预编译的装置400,运行于电子设备,所述装置400包括:
状态检测单元410,用于检测所述电子设备当前的运行状态。
作为一种方式,所述安装阶段包括所述应用程序的安装包安装阶段或者所述应用程序的更新文件安装阶段。
信息获取单元420,用于若所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的配置文件,所述配置文件中存储有所述应用程序对应的热点编译单元。
作为一种方式,信息获取单元420,还用于若所述运行状态满足指定条件,且所述应用程序的配置文件在所述安装阶段未进行预编译,获取所述应用程序对应的配置文件。
可选的,若在应用程序处于安装阶段时,所述指定条件包括:所述电子设备处于灭屏状态;若在应用程序不处于安装阶段时,所述指定条件包括:所述电子设备的电量满足指定电量阈值、所述电子设备的可用存储空间不小于指定空间阈值以及所述电子设备的温度不高于指定温度阈值中的至少一个。
编译单元430,用于对所述热点编译单元进行预编译。
作为一种方式,编译单元430,还用于在对所述热点编译单元进行预编译的过程中,若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,暂停对剩余未编译的热点编译单元进行编译;在所述暂停状态下,检测到所述电子设备满足恢复条件时,恢复对所述未编译的热点编译单元进行编译。
在这种方式下,编译单元430,具体用于若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,在继续完成当前所编译的热点编译单元的编译操作后,暂停对剩余未编译的热点编译单元进行编译。其中,可选的,编译单元430,具体用于若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,检测当前正在编译的热点编译单元所属的功能模块;若所述功能模块属于指定的常用功能模块,在继续完成当前所编译的热点编译单元的编译操作后,暂停对剩余未编译的热点编译单元进行编译。
作为一种方式,所述恢复条件包括:所述电子设备处于灭屏状态;所述电子设备处于充电状态;或者所述电子设备处理空闲状态。
如图9所示,状态检测单元410,具体包括:
应用程序检测子单元411,用于当处于应用程序的安装阶段时,检测所述应用程序是否属于预配置的应用程序;
状态检测子单元412,用于若属于所述预配置的应用程序,检测所述电子设备当前的运行状态。
下面将结合图10对本申请提供的一种电子设备进行说明。
请参阅图10,基于上述的图像处理方法、装置,本申请实施例还提供的另一种可以执行前述应用程序预编译的方法的电子设备200。电子设备200包括相互耦合的一个或多个(图中仅示出一个)处理器102、存储器104以及网络模块106。其中,该存储器104中存储有可以执行前述实施例中内容的程序,而处理器102可以执行该存储器104中存储的程序。
其中,处理器102可以包括一个或者多个处理核。处理器102利用各种接口和线路连接整个电子设备100内的各个部分,通过运行或执行存储在存储器104内的指令、程序、代码集或指令集,以及调用存储在存储器104内的数据,执行电子设备100的各种功能和处理数据。可选地,处理器102可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array, PLA)中的至少一种硬件形式来实现。处理器102可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作系统、用户界面和应用程序等;GPU用于负责显示内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器102中,单独通过一块通信芯片进行实现。
存储器104可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。例如,存储器104中可以存储有应用程序预编译的装置。该应用程序预编译的装置可以为前述的装置400。存储器104可用于存储指令、程序、代码、代码集或指令集。存储器104可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作系统的指令、用于实现至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现下述各个方法实施例的指令等。存储数据区还可以存储终端100在使用中所创建的数据(比如电话本、音视频数据、聊天记录数据)等。
所述网络模块106用于接收以及发送电磁波,实现电磁波与电信号的相互转换,从而与通讯网络或者其他设备进行通讯,例如和无线接入点进行通讯。所述网络模块106可包括各种现有的用于执行这些功能的电路元件,例如,天线、射频收发器、数字信号处理器、加密/解密芯片、用户身份模块(SIM)卡、存储器等等。所述网络模块106,还可以作为网络适配器,用于电子设备200直接通过线路连接的方式接入到网络中。该网络可包括蜂窝式电话网、无线局域网或者城域网。
请参考图11,其示出了本申请实施例提供的一种计算机可读存储介质的结构框图。该计算机可读介质800中存储有程序代码,所述程序代码可被处理器调用执行上述方法实施例中所描述的方法。
计算机可读存储介质800可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。可选地,计算机可读存储介质800包括非易失性计算机可读介质(non-transitory computer-readable storage medium)。计算机可读存储介质800具有执行上述方法中的任何方法步骤的程序代码810的存储空间。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。程序代码810可以例如以适当形式进行压缩。
综上所述,本申请提供的一种应用程序预编译的方法、装置、电子设备及存储介质,当检测所述电子设备的所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的储有所述应用程序对应的热点编译单元的配置文件,对所述热点编译单元进行预编译。从而检测电子设备的运行状态的方式,使得只有在运行状态满足指定条件才会进行配置文件中的热点编译单元的预编译操作,使得热点编译单元的编译时机具有可配置性,而不会直接在应用程序安装阶段就直接对热点编译单元进行编译造成电子设备的运行性能受到影响。
最后应说明的是:以上实施例仅用以说明本申请的技术方案,而非对其限 制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不驱使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种应用程序预编译的方法,其特征在于,应用于电子设备,所述方法包括:
    检测所述电子设备当前的运行状态;
    若所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的配置文件,所述配置文件中存储有所述应用程序对应的热点编译单元;
    对所述热点编译单元进行预编译。
  2. 根据权利要求1所述的方法,其特征在于,所述方法,还包括:
    若所述运行状态不满足指定条件,且应用程序处于安装阶段时,不对所述热点编译单元进行预编译。
  3. 根据权利要求2所述的方法,其特征在于,所述若所述运行状态不满足指定条件,且应用程序处于安装阶段时,不对所述热点编译单元进行预编译之后,还包括:
    若所述运行状态满足指定条件,且所述应用程序的配置文件在所述安装阶段未进行预编译,获取所述应用程序对应的配置文件;
    对所述热点编译单元进行预编译。
  4. 根据权利要求1所述的方法,其特征在于,所述检测所述电子设备当前的运行状态,包括:
    检测所述电子设备的处理器的剩余处理资源是否不小于指定资源阈值;
    若所述剩余处理资源不小于所述指定资源阈值,判定所述运行状态满足指定条件。
  5. 根据权利要求4所述的方法,其特征在于,所述电子设备包括屏幕,所述检测所述电子设备当前的运行状态,包括:
    检测所述屏幕的运行状态以及所述电子设备的处理器的剩余处理资源;
    若所述屏幕的运行状态处于熄屏状态,且所述剩余处理资源不低于指定阈值,判定所述电子设备的运行状态满足指定条件,所述指定阈值低于所述指定资源阈值。
  6. 根据权利要求1所述的方法,其特征在于,所述电子设备包括屏幕,所述检测所述电子设备当前的运行状态,包括:
    检测所述屏幕的运行状态;
    若处于熄屏状态,判定所述运行状态满足指定条件;
    若处于亮屏状态,判定所述运行状态不满足指定条件。
  7. 根据权利要求1-6任一项所述的方法,其特征在于,所述方法,还包括:
    在对所述热点编译单元进行预编译的过程中,若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,暂停对剩余未编译的热点编译单元进行编译;
    在所述暂停状态下,检测到所述电子设备满足恢复条件时,恢复对所述未编译的热点编译单元进行编译。
  8. 根据权利要求7所述的方法,其特征在于,所述恢复条件包括:所述电子设备处于灭屏状态、所述电子设备处于空闲状态或所述电子设备处于充电状态。
  9. 根据权利要求7所述的方法,其特征在于,所述若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,暂停对剩余未编译的热点编译单元进行编译,包括:
    若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,在继续完成当前所编译的热点编译单元的编译操作后,暂停对剩余未编译的热点编译单元进行编译。
  10. 根据权利要求9所述的方法,其特征在于,所述应用程序包括多个功能模块,每个功能模块包括有多个热点编译单元,所述若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,在继续完成当前所编译的热点编译单元的编译操作后,暂停对剩余未编译的热点编译单元进行编译,包括:
    若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,检测当前正在编译的热点编译单元所属的功能模块;
    若所述功能模块属于指定的常用功能模块,在继续完成当前所编译的热点编译单元的编译操作后,暂停对剩余未编译的热点编译单元进行编译。
  11. 根据权利要求10所述的方法,其特征在于,所述方法,还包括:
    若所述功能模块属于非常用功能模块,暂停编译所有的剩余未编译的内容,所述所有的剩余未编译的内容包括当前正在编译的热点编译单元剩余的未编译内容,以及剩余的还未开始编译的热点编译单元。
  12. 根据权利要求1-11任一项所述的方法,其特征在于,所述方法,还包括:
    若所述运行状态不满足指定条件,周期性检测所述电子设备是否满足所述指定条件,直到检测到所述电子设备满足所述指定条件,且对所述热点编译单元进行预编译。
  13. 根据权利要求1-12任一项所述的方法,其特征在于,若在应用程序处于安装阶段时,所述指定条件包括:所述电子设备处于灭屏状态;
    若在应用程序不处于安装阶段时,所述指定条件包括:所述电子设备的电量满足指定电量阈值、所述电子设备的可用存储空间不小于指定空间阈值以及所述电子设备的温度不高于指定温度阈值中的至少一个。
  14. 根据权利要求1-13任一项所述的方法,其特征在于,所述获取所述应用程序对应的配置文件的步骤之前,还包括:
    检测所述应用程序是否属于预配置的应用程序;
    若属于所述预配置的应用程序,执行所述获取所述应用程序对应的配置文件。
  15. 根据权利要求1-14任一项所述的方法,其特征在于,所述安装阶段包括所述应用程序的安装包安装阶段或者所述应用程序的更新文件安装阶段。
  16. 一种应用程序预编译的装置,其特征在于,运行于电子设备,所述装置包括:
    状态检测单元,用于检测所述电子设备当前的运行状态;
    信息获取单元,用于若所述运行状态满足指定条件,且应用程序处于安装阶段时,获取所述应用程序对应的配置文件,所述配置文件中存储有所述应用程序对应的热点编译单元;
    编译单元,用于对所述热点编译单元进行预编译。
  17. 根据权利要求16所述的装置,其特征在于,所述信息获取单元,还用于:
    若所述运行状态满足指定条件,且所述应用程序的配置文件在所述安装阶段未进行预编译,获取所述应用程序对应的配置文件。
  18. 根据权利要求16所述的装置,其特征在于,所述编译单元,还用于:
    在对所述热点编译单元进行预编译的过程中,若检测到所述电子设备的运行状态切换为不满足所述指定条件的状态时,暂停对剩余未编译的热点编译单元进行编译;
    在所述暂停状态下,检测到所述电子设备满足恢复条件时,恢复对所述未编译的热点编译单元进行编译。
  19. 一种电子设备,其特征在于,包括一个或多个处理器以及存储器;
    其中,一个或多个程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行权利要求1-15任一项所述的方法。
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有程序代码,其中,在所述程序代码被处理器运行时执行权利要求1-15任一项所述的方法。
PCT/CN2020/136887 2019-12-24 2020-12-16 应用程序预编译的方法、装置、电子设备及存储介质 WO2021129489A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911349773.XA CN113031955A (zh) 2019-12-24 2019-12-24 应用程序预编译的方法、装置以及电子设备
CN201911349773.X 2019-12-24

Publications (1)

Publication Number Publication Date
WO2021129489A1 true WO2021129489A1 (zh) 2021-07-01

Family

ID=76452166

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/136887 WO2021129489A1 (zh) 2019-12-24 2020-12-16 应用程序预编译的方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN113031955A (zh)
WO (1) WO2021129489A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116661909A (zh) * 2023-08-01 2023-08-29 北京小米移动软件有限公司 应用程序的运行方法、装置、终端设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105022647A (zh) * 2015-07-15 2015-11-04 深圳市金立通信设备有限公司 一种应用安装的控制方法及终端
US20160342410A1 (en) * 2015-05-22 2016-11-24 Xiaomi Inc. Method and apparatus for processing application installation package
CN106775828A (zh) * 2016-11-25 2017-05-31 广东欧珀移动通信有限公司 应用程序安装方法及装置、计算机设备
CN108804110A (zh) * 2018-06-15 2018-11-13 Oppo(重庆)智能科技有限公司 一种数据处理方法、数据处理装置及移动终端
CN111061484A (zh) * 2019-11-28 2020-04-24 Oppo广东移动通信有限公司 代码编译方法、装置、服务器、用户终端及可读介质

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107861730B (zh) * 2017-10-27 2020-10-30 维沃移动通信有限公司 一种应用程序的处理方法及移动终端
CN109960507B (zh) * 2017-12-14 2021-06-08 Oppo广东移动通信有限公司 编译优化方法、装置、存储介质、智能终端及服务器

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160342410A1 (en) * 2015-05-22 2016-11-24 Xiaomi Inc. Method and apparatus for processing application installation package
CN105022647A (zh) * 2015-07-15 2015-11-04 深圳市金立通信设备有限公司 一种应用安装的控制方法及终端
CN106775828A (zh) * 2016-11-25 2017-05-31 广东欧珀移动通信有限公司 应用程序安装方法及装置、计算机设备
CN108804110A (zh) * 2018-06-15 2018-11-13 Oppo(重庆)智能科技有限公司 一种数据处理方法、数据处理装置及移动终端
CN111061484A (zh) * 2019-11-28 2020-04-24 Oppo广东移动通信有限公司 代码编译方法、装置、服务器、用户终端及可读介质

Also Published As

Publication number Publication date
CN113031955A (zh) 2021-06-25

Similar Documents

Publication Publication Date Title
CN109213539B (zh) 一种内存回收方法及装置
CN107832100B (zh) 一种apk插件的加载方法及其终端
WO2021057619A1 (zh) 内存回收方法、装置、电子设备及存储介质
CN105677335A (zh) 提高移动终端首次开机速度的方法及装置
WO2019024649A1 (zh) 应用程序的启动方法、装置、存储介质和终端
US20190188030A1 (en) Terminal background application management method and apparatus
WO2021057622A1 (zh) 内存回收方法、装置、电子设备及存储介质
AU2019256257B2 (en) Processor core scheduling method and apparatus, terminal, and storage medium
US20190109767A1 (en) Network bandwidth management method, terminal and computer storage medium
CN106066686A (zh) 一种信息处理方法及终端设备
CN106937258B (zh) 一种广播的控制方法、装置及移动终端
CN111050378B (zh) 网络搜索方法、装置及电子设备
WO2021057623A1 (zh) 内存回收方法、装置、电子设备及存储介质
WO2021115177A1 (zh) 应用安装方法、装置、终端设备、服务器及存储介质
CN103713943A (zh) 基于终端原生操作系统的应用功能实现方法和装置
CN111104180B (zh) 应用程序优化方法、装置、存储介质及电子设备
CN111273769B (zh) 一种设备控制方法、装置、电子设备及存储介质
WO2021129489A1 (zh) 应用程序预编译的方法、装置、电子设备及存储介质
CN104375854A (zh) 一种应用更新下载方法及用户终端
CN111352647A (zh) 虚拟机升级方法、装置、设备及存储介质
WO2020118601A1 (zh) 视频编码方法、装置、电子设备及存储介质
CN112799696B (zh) 固件升级方法和相关设备
CN112540769A (zh) 编译处理方法、装置、电子设备以及存储介质
CN110069322B (zh) 后台应用的处理方法、终端设备及存储介质
CN106970812B (zh) 升级文件处理、装置及终端

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20904778

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20904778

Country of ref document: EP

Kind code of ref document: A1