Method, device, system and medium for optimizing application code

By comparing the static and dynamic information of the application, determining the shared code blocks and optimizing it, the problems of compilation time and code complexity caused by the increase in the amount of code in the software system are solved, and the simplicity and performance of the code are improved.

CN112148292BActive Publication Date: 2025-03-18BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910583412.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-28
Publication Date
2025-03-18
Estimated Expiration
2039-06-28

AI Technical Summary

Technical Problem

With the expansion and update of business, the amount of code in the software system increases, resulting in the extension of compilation time and the complex references between code modules, making it difficult to manage and optimize.

Method used

By obtaining the static and dynamic information of the application's code, determine the common code blocks involved in both the static and dynamic information, and optimize the application's code based on these common code blocks, including merging, replacing or deleting unnecessary code.

Benefits of technology

It simplifies the code structure of the software system, reduces storage capacity and data transmission, and improves the performance and maintainability of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112148292B_ABST
    Figure CN112148292B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method for optimizing the code of an application. The method comprises: obtaining static information of the code of the application, wherein the static information includes information possessed by a code block in the code of the application; obtaining dynamic information of the code of the application, wherein the dynamic information includes information possessed by a code block in the code of the application based on interactive use of the application by a user; determining common code blocks among the code blocks involved in the static information and the code blocks involved in the dynamic information; and optimizing the code of the application based on the common code blocks. The present disclosure also provides a device, system and medium for optimizing the code of an application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of Internet technology, and more specifically, to a method, device, system and medium for optimizing application code. Background Art

[0002] During the development, operation and upgrade of software systems (for example, applications that can be applied to iOS or Android systems), as the business continues to expand and update, the amount of code will increase accordingly, causing the entire software system to become extremely large, and the mutual references between code modules become intertwined and complex, which in turn increases the compilation time of the software system. How to more reasonably manage the code in the software system, or how to accurately locate and remove unnecessary zombie code to keep the code in the software system concise and reasonable, is an urgent problem to be solved. Summary of the invention

[0003] In view of this, the present disclosure provides a method, device, system and medium for optimizing application code.

[0004] One aspect of the present disclosure provides a method for optimizing the code of an application. The method includes: obtaining static information of the code of the application, wherein the static information includes information possessed by a code block in the code of the application; obtaining dynamic information of the code of the application, wherein the dynamic information includes information possessed by a code block in the code of the application based on interactive use of the application by a user; determining a common code block among the code blocks involved in the static information and the code blocks involved in both the dynamic information; and optimizing the code of the application based on the common code block.

[0005] According to an embodiment of the present disclosure, the code of the application program includes at least one of the following: a program module, a function code block, a class code block, or a class method code block.

[0006] According to an embodiment of the present disclosure, optimizing the code of the application based on the common code blocks includes determining that at least a portion of the code blocks involved in the static information other than the common code blocks is zombie code, and deleting the zombie code.

[0007] According to an embodiment of the present disclosure, the acquiring of static information of the code of the application includes acquiring the static information during the development phase of the application.

[0008] According to an embodiment of the present disclosure, the method further includes inserting at least one dynamic tracking point into the code of the application, and the at least one dynamic tracking point is used to collect the dynamic information after the application is released.

[0009] According to an embodiment of the present disclosure, the method further includes setting a burying point switch for each of the at least one dynamic burying point.

[0010] According to an embodiment of the present disclosure, the dynamic information of the code of the application is obtained, including configuring each dynamic burying point based on the switch state of the burying point switch of each dynamic burying point, and collecting the dynamic information through a dynamic burying point whose switch state is on among at least one dynamic burying point.

[0011] Another aspect of the present disclosure provides a device for optimizing the code of an application. The device includes a code static information acquisition module, a code dynamic information acquisition module, a comparison hit module, and an optimization module. The code static information acquisition module is used to obtain static information of the code of the application, and the static information includes information possessed by the code blocks in the code of the application. The code dynamic information acquisition module is used to obtain dynamic information of the code of the application, and the dynamic information includes information possessed by the code blocks in the code of the application based on the user's interactive use of the application. The comparison hit module is used to determine the common code blocks in the code blocks involved in the static information and the code blocks involved in both the dynamic information. The optimization module is used to optimize the code of the application based on the common code blocks.

[0012] According to an embodiment of the present disclosure, the optimization module is used to determine that at least a portion of the code blocks involved in the static information, except for the common code blocks, are zombie codes, and delete the zombie codes.

[0013] According to an embodiment of the present disclosure, the code static information acquisition module is used to acquire the static information during the development phase of the application.

[0014] According to an embodiment of the present disclosure, the device further comprises a tracking point insertion module. The tracking point insertion module is used to insert at least one dynamic tracking point into the code of the application, and the at least one dynamic tracking point is used to collect the dynamic information after the application is released.

[0015] According to an embodiment of the present disclosure, the device further includes a configuration module. The configuration module is used to set a burying point switch for each dynamic burying point in the at least one dynamic burying point.

[0016] According to an embodiment of the present disclosure, the code dynamic information acquisition module is specifically used to obtain dynamic information of the code of the application, including configuring each dynamic burying point based on the switch state of the burying point switch of each dynamic burying point, and collecting the dynamic information through a dynamic burying point whose switch state is on among at least one dynamic burying point.

[0017] Another aspect of the present disclosure provides a system for optimizing the code of an application program. The system includes one or more memories and one or more processors. The one or more memories store executable instructions. The one or more processors execute the executable instructions to implement the method described above.

[0018] Another aspect of the present disclosure provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to perform the method described above.

[0019] Another aspect of the present disclosure provides a computer program, which includes computer executable instructions, and the instructions are used to implement the method described above when executed.

[0020] According to an embodiment of the present disclosure, by comparing the static information and dynamic information of the application code (e.g., each program module, function code block in the program module, class code block, or class method code block, etc.), the common code blocks in the code blocks involved in the static information and the code blocks involved in the dynamic information are determined, and the application code is optimized based on the common code blocks. In this way, on the one hand, some program modules or data classes can be simplified or merged based on the number of calls or call frequencies of the common code blocks, and on the other hand, zombie codes in the application can be more accurately located and deleted, thereby improving the simplicity of the application code. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0022] Figure 1A The application scenarios of the method, device, system and medium for optimizing the code of an application program according to the embodiments of the present disclosure are schematically shown;

[0023] Figure 1B The technical architecture of the method for optimizing the code of an application program according to an embodiment of the present disclosure is schematically shown;

[0024] Figure 2 A flowchart schematically shows a method for optimizing application code according to an embodiment of the present disclosure;

[0025] Figure 3 A flowchart schematically shows a method for optimizing application code according to another embodiment of the present disclosure;

[0026] Figure 4 The implementation process of optimizing the code of an application based on a common code block according to an embodiment of the present disclosure is schematically shown;

[0027] Figure 5 A block diagram schematically shows an apparatus for optimizing application code according to an embodiment of the present disclosure; and

[0028] Figure 6 A block diagram of a computer system for optimizing application code according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0029] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0030] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0031] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0032] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0033] The embodiments of the present disclosure provide a method, device, system and medium for optimizing the code of an application. The method includes: obtaining static information of the code of the application, wherein the static information includes information possessed by a code block in the code of the application; obtaining dynamic information of the code of the application, wherein the dynamic information includes information possessed by a code block in the code of the application based on the interactive use of the application by a user; determining the common code blocks in the code blocks involved in the static information and the code blocks involved in the dynamic information; and optimizing the code of the application based on the common code blocks.

[0034] According to an embodiment of the present disclosure, by comparing the static information and dynamic information of the code of the application (for example, each program module, function code block in the module, class code block, or class method code block, etc.), the common code blocks in the code blocks involved in the static information and the code blocks involved in the dynamic information are determined, and the code of the application is optimized based on the common code blocks. In this way, the program modules, function code blocks, class code blocks, or class method code blocks in the application can be merged, replaced, or deleted based on these common code blocks, so that the code in the software system remains concise and reasonable, which can reduce the storage capacity of the software system on the one hand, and reduce the amount of data transmission when the client downloads the application on the other hand.

[0035] Figure 1A The application scenario 100 of the method, device, system and medium for optimizing the code of an application program according to an embodiment of the present disclosure is schematically shown. It should be noted that: Figure 1A What is shown are merely examples of application scenarios to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0036] like Figure 1A As shown, the application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0037] The terminal devices 101, 102, 103 may be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc. Users may use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various client applications may be installed on the terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples). Dynamic embedding points may be inserted into the application of the client application, so that when the user uses the client application installed in the terminal devices 101, 102, 103, the usage / rate, click rate, browsing rate, and other dynamic information of the client application code may be collected through dynamic embedding points (for example, a dynamic information statistical report may be formed). Furthermore, the dynamic information may also be sent to the server 105 through a tool with a sending function such as a embedding reporting tool 112.

[0038] The server 105 may be a server that provides various services, such as a background management server that provides support for websites browsed by users using terminal devices 101, 102, and 103 (for example only). According to an embodiment of the present disclosure, the server 105 may receive and obtain dynamic information of the application code sent from the terminal devices 101, 102, and 103 (for example, to form a dynamic information report). According to another embodiment of the present disclosure, program developers may also use the server 105 to obtain static information of the application code, such as obtaining static information of the application code through a static code scanning tool (for example, a code scanning tool ACSTool script) during the development phase of the application (for example, to form a static information statistical report). Then, according to the embodiment of the present disclosure, the server 105 can compare the static information statistical report and the dynamic information statistical report to determine the common code blocks in the code blocks involved in the static information and the code blocks involved in the dynamic information (for example, program modules, function code blocks in modules, class code blocks, or class method code blocks, etc.). These common code blocks are code blocks used by users during the operation of the application. Based on these common code blocks, the server 105 can merge, replace or delete program modules, function code blocks, class code blocks, or class method code blocks in the application, so as to keep the code in the software system concise and reasonable. On the one hand, it can reduce the storage volume of the software system, and on the other hand, it can also reduce the amount of data transmission when the client downloads the application.

[0039] It should be noted that the method for optimizing the code of the application provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the device for optimizing the code of the application provided in the embodiment of the present disclosure can generally be set in the server 105. The method for optimizing the code of the application provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the device for optimizing the code of the application provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.

[0040] It should be understood that Figure 1A The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0041] Figure 1B The technical architecture of the method for optimizing the code of an application program according to an embodiment of the present disclosure is schematically shown.

[0042] like Figure 1B As shown, the technical architecture of the method for optimizing the code of an application according to an embodiment of the present disclosure may include a tracking tool system 110, an information database 120, and a statistics server 130.

[0043] The tracking tool system 110 may include a tool 111 for acquiring static information and a tool 112 for acquiring dynamic information. The information database 120 is used to store the static information of the application acquired by the tool 111 for acquiring static information (e.g., static information statistical reports), and the dynamic information of the application acquired by the tool 112 for acquiring dynamic information (e.g., dynamic information statistical reports). The statistics server 130 may be used to configure and manage the tracking tool system 110, and to compare the static information statistical reports with the dynamic information statistical reports to determine the common code blocks in the code blocks involved in the static information and the code blocks involved in both the dynamic information, which may then be used to optimize the code design of the application based on the common code blocks.

[0044] The tool 111 for acquiring static information may be, for example, an independent code scanning tool ACSTool script 111. The code scanning tool ACSTool script 111 may be used to scan the code of an application program, thereby obtaining static information of the code of the application program. In one embodiment of the present disclosure, the code scanning tool ACSTool script 111 may output the static information obtained by scanning the code of the application program (for example, scanning and identifying the class code blocks and method code blocks of the Objective-C and Swift programming languages) to the information database 120 in the form of a static information statistical report. According to one embodiment of the present disclosure, the code scanning tool ACSTool script 111 may also be used to insert at least one dynamic embedding point into the code of the application program, so as to collect dynamic information of the code of the application program using these dynamic embedding points after the application program is compiled and released. Specifically, for example, the code scanning tool ACSTool script 111 may be used to insert embedding point macros into code blocks such as class code blocks and method code blocks, wherein the embedding point macros may be configured with macro categories and / or switches, etc.

[0045] The tool 112 for obtaining dynamic information may be, for example, a tracking point reporting tool 112 embedded in an application. The tracking point reporting tool 112 may exist in the form of an independent functional module and a statistical code macro inserted into various initializations and methods, and may be written in Objective C, Swift, or C++. The tracking point reporting tool 112 may be used to obtain dynamic information of an application collected by dynamic tracking points, and output the dynamic information to the information database 120. In one embodiment of the present disclosure, the tracking point reporting tool 112 may output the dynamic information to the information database 120 in the form of a dynamic information statistical report.

[0046] The statistics server 130 can provide a report management service. The report management service can be used to compare the static information statistics report and the dynamic information statistics report to determine the common code blocks. For example, the statistics server 130 can compare the static information statistics report and the dynamic information statistics report and output an actual use report, and optimize the code design of the application according to the actual use report. The code blocks involved in the actual use report are the common code blocks, wherein the common code blocks reflect the code blocks used by users after the application is released.

[0047] According to other embodiments of the present disclosure, the technical architecture may further include a configuration database 140. The configuration database 140 may be used to record information on the switch status actually configured for each dynamic burying point in at least one dynamic burying point. In practice, the release of an application program is different according to the software version, device model, usage area, and population type, and it is often necessary to selectively turn on the switches of some dynamic burying points in the application program. Therefore, the switch status information recorded in the configuration database 140 can provide a reference for the statistical server 130 to compare static information statistical reports and dynamic information statistical reports. For example, only the static information of the code blocks whose switch status of the dynamic burying points is on can be selected for comparison with the dynamic information.

[0048] According to an embodiment of the present disclosure, the statistics server 130 may be the server 105. The tracking tool system 110 may be disposed in the statistics server 130 and constitute a part of the statistics server 130.

[0049] It should be understood that Figure 1B The technical architecture in the description is merely illustrative, and is used to illustrate the implementation process of the embodiments of the present disclosure, and does not constitute any limitation to the present disclosure.

[0050] Figure 2 The flowchart of the method for optimizing the code of an application program according to an embodiment of the present disclosure is schematically shown.

[0051] like Figure 2 As shown, according to an embodiment of the present disclosure, the method for optimizing the code of an application may include operations S210 to S240.

[0052] In operation S210, static information of the code of the application is obtained, and the static information includes information of the code block itself in the code of the application. Figure 1B The static information obtained by the tool 111 for obtaining static information is shown.

[0053] The code block of an application is a common form of code, which can be an independent code area formed by encapsulating at least one line of code together, and can complete relatively independent data processing operations. In Java, a code block can be enclosed in "{}". According to an embodiment of the present disclosure, the code of the application includes at least one of the following: a program module, a function code block, a class code block, or a class method code block. The static information can be, for example, the name of the code block, or version information, etc. The version information can identify the version of each code block. In this way, if the static information includes different versions of code blocks that are functionally repeated, the different versions of the code blocks can be filtered according to the version information.

[0054] In operation S220, dynamic information of the code of the application is obtained, wherein the dynamic information includes information that a code block in the code of the application has based on the user's interactive use of the application. Figure 1B The tool 112 for acquiring dynamic information acquires the dynamic information, which may be the number of times / frequency of use of a code block, the time range of use, etc.

[0055] In operation S230 , common code blocks among the code blocks involved in the static information and the code blocks involved in the dynamic information are determined.

[0056] In operation S240 , the code of the application is optimized based on the common code blocks.

[0057] According to an embodiment of the present disclosure, by comparing the static information and dynamic information of the code of the application (for example, each program module, function code block in the module, class code block, or class method code block, etc.), the common code blocks in the code blocks involved in the static information and the code blocks involved in the dynamic information are determined, and the code of the application is optimized based on the common code blocks. In this way, the program modules, function code blocks, class code blocks, or class method code blocks in the application can be merged, replaced, or deleted based on these common code blocks, so that the code in the software system can be kept concise and reasonable, which can reduce the storage capacity of the software system on the one hand, and reduce the amount of data transmission when the client downloads the application on the other hand.

[0058] Figure 3 The flowchart of a method for optimizing application code according to another embodiment of the present disclosure is schematically shown.

[0059] like Figure 3 As shown, according to another embodiment of the present disclosure, the method for optimizing the code of an application program includes operations S211 to S240. Figure 2 The operation S210 described in the above can be specifically implemented as follows: Figure 3 In operation S211, Figure 2 The operation S220 described in the above can be specifically implemented as follows: Figure 3 Operation S221 and operation S222, operation S230 and operation S240 in Figure 2 The description is similar. In addition, Figure 3 The method flow shown also includes operation S310 and operation S320. Figure 3 A detailed description of the method flow shown is as follows.

[0060] In operation S211, static information can be obtained during the development phase of the application. Figure 1BDuring the development phase of the application, the statistics server 130 can scan and obtain the static information by notifying the management service instruction code scanning tool ACSTool script 111.

[0061] Then, in operation S310, at least one dynamic tracking point is inserted into the code of the application program, and the at least one dynamic tracking point is used to collect the dynamic information after the application program is released. Figure 1B During the development phase of the application, the statistics server 130 can instruct the code scanning tool ACSTool script 111 to insert the at least one dynamic embedding point into the code of the application while scanning the code of the application through the notification management service.

[0062] If the code scanning tool ACSTool script 111 sets a switch parameter for each dynamic burying point when inserting the at least one dynamic burying point, then according to an embodiment of the present disclosure, a burying point switch can be set for each dynamic burying point in the at least one dynamic burying point in operation S320. Thus, dynamic information of the application code can be obtained by executing operations S221 and S222.

[0063] In operation S221, each dynamic burying point is configured based on the switch state of the burying point switch of each dynamic burying point. Figure 1B The statistics server 130 is used to configure the switch status of each dynamic burying point, and the switch information actually configured for each dynamic burying point in at least one dynamic burying point is stored in the configuration information library 140.

[0064] In operation 222, dynamic information is collected through a dynamic buried point whose switch state is open among the at least one dynamic buried point.

[0065] Operation S230 and operation S240 may be performed thereafter.

[0066] Figure 4 The implementation process of optimizing the code of the application based on the common code blocks in operation S240 according to an embodiment of the present disclosure is schematically shown.

[0067] As shown in FIG. 4 , according to an embodiment of the present disclosure, operation S240 may be specifically implemented as operation S401 and operation S402 .

[0068] In operation S401, it is determined that at least a portion of the code in the code blocks involved in the static information, except for the common code blocks, is zombie code. In some embodiments, when a switch is set for at least one dynamic burying point, the code in the code blocks involved in the dynamic burying points whose burying point switch is on, except for the common code blocks, can be regarded as zombie code.

[0069] In operation S402, the zombie code is deleted. In this way, the simplicity of the application code can be improved and the occupied volume of the application can be reduced.

[0070] Figure 5 A block diagram of an apparatus 500 for optimizing application code according to an embodiment of the present disclosure is schematically shown.

[0071] like Figure 5 As shown, according to some embodiments of the present disclosure, the device 500 for optimizing the code of an application includes a code static information acquisition module 510, a code dynamic information acquisition module 520, a comparison hit module 530, and an optimization module 540. According to other embodiments of the present disclosure, the device 500 also includes a point insertion module 550. According to still other embodiments of the present disclosure, the device 500 also includes a configuration module 560. According to an embodiment of the present disclosure, the device 500 can be used to execute a method for optimizing the code of an application according to an embodiment of the present disclosure.

[0072] The code static information acquisition module 510 can, for example, perform operation S210 to obtain static information of the code of the application, where the static information includes information possessed by the code blocks in the code of the application. According to an embodiment of the present disclosure, the code static information acquisition module 510 can specifically perform operation S211 to obtain the static information during the development phase of the application.

[0073] The code dynamic information acquisition module 520 may, for example, perform operation 220 to acquire dynamic information of the code of the application, wherein the dynamic information includes information that a code block in the code of the application has based on the user's interactive use of the application.

[0074] The comparison hit module 530 may, for example, perform operation S230 to determine the common code blocks in the code blocks involved in the static information and the code blocks involved in both the dynamic information.

[0075] The optimization module 540 may, for example, perform operation S240 to optimize the code of the application program based on the common code blocks.

[0076] According to an embodiment of the present disclosure, the optimization module 540 may specifically perform operations S401 and S402 to determine that at least a portion of the code blocks involved in the static information other than the common code blocks are zombie codes, and delete the zombie codes.

[0077] According to an embodiment of the present disclosure, the burying point insertion module 550 may, for example, perform operation S310, for inserting at least one dynamic burying point into the code of the application, and the at least one dynamic burying point is used to collect dynamic information after the application is released. According to an embodiment of the present disclosure, the configuration module 560 may, for example, perform operation S320, for setting a burying point switch for each dynamic burying point in at least one dynamic burying point. According to an embodiment of the present disclosure, the code dynamic information acquisition module 520 may, for example, specifically perform operations S221 and S222, for obtaining dynamic information of the code of the application, including configuring each dynamic burying point based on the switch state of the burying point switch of each dynamic burying point, and collecting dynamic information through a dynamic burying point whose switch state is on in at least one dynamic burying point.

[0078] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.

[0079] For example, any multiple of the code static information acquisition module 510, the code dynamic information acquisition module 520, the comparison hit module 530, the optimization module 540, the buried point insertion module 550, and the configuration module 560 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the code static information acquisition module 510, the code dynamic information acquisition module 520, the comparison hit module 530, the optimization module 540, the buried point insertion module 550, and the configuration module 560 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware and firmware or by a suitable combination of any of them. Alternatively, at least one of the code static information acquisition module 510, the code dynamic information acquisition module 520, the comparison hit module 530, the optimization module 540, the embedding point insertion module 550, and the configuration module 560 can be at least partially implemented as a computer program module, and when the computer program module is executed, the corresponding function can be executed.

[0080] Figure 6 The block diagram of a computer system 600 for optimizing application code according to an embodiment of the present disclosure is schematically shown. Figure 6 The computer system 600 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0081] like Figure 6 As shown, the computer system 600 according to the embodiment of the present disclosure includes a processor 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage part 608 to the random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.

[0082] In RAM 603, various programs and data required for the operation of system 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other through bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in one or more memories.

[0083] According to an embodiment of the present disclosure, the system 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The system 600 may further include one or more of the following components connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 606 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0084] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0085] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0086] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 602 and / or RAM 603 described above and / or one or more memories other than ROM 602 and RAM 603.

[0087] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0088] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0089] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A method for optimizing application code, comprising: Obtaining static information of the code of the application, wherein the static information includes information possessed by a code block in the code of the application; Acquire dynamic information of the code of the application, wherein the dynamic information includes information of a code block in the code of the application based on interactive use of the application by a user; wherein the dynamic information includes a usage rate, a click rate, or a browsing rate of a code block in the code of the application; Determine a common code block among the code blocks involved in the static information and the code blocks involved in both the dynamic information; and Optimizing the code of the application based on the common code blocks includes: merging some code blocks based on the number of calls or the calling frequency of the common code blocks.

2. The method according to claim 1, wherein: The code block in the code of the application program includes at least one of the following: A program module, a function code block, a class code block, or a class method code block.

3. The method according to claim 1 or 2, wherein: The optimizing the code of the application based on the common code block comprises: Determine that at least a portion of the code blocks involved in the static information, except for the common code blocks, are zombie codes; and Delete said zombie code.

4. The method according to claim 1 or 2, wherein: The static information of obtaining the code of the application program includes: The static information is obtained during the development phase of the application.

5. The method according to claim 1 or 2, wherein: The method further comprises: At least one dynamic embedding point is inserted into the code of the application, and the at least one dynamic embedding point is used to collect the dynamic information after the application is released.

6. The method according to claim 5, wherein: The method further comprises: A burying point switch is set for each dynamic burying point of the at least one dynamic burying point.

7. The method according to claim 6, wherein: The dynamic information of obtaining the code of the application program includes: Configure each dynamic burying point based on the switch state of the burying point switch of each dynamic burying point; and The dynamic information is collected through a dynamic buried point whose switch state is open among the at least one dynamic buried point.

8. A device for optimizing code of an application, comprising: A code static information acquisition module, used to acquire static information of the code of the application, wherein the static information includes information possessed by a code block in the code of the application; A code dynamic information acquisition module, used to acquire dynamic information of the code of the application, wherein the dynamic information includes information of a code block in the code of the application based on interactive use of the application by a user; wherein the dynamic information includes a usage rate, a click rate or a browsing rate of a code block in the code of the application; A comparison hit module, used to determine the common code blocks in the code blocks involved in the static information and the code blocks involved in both the dynamic information; and The optimization module is used to optimize the code of the application based on the common code blocks, including: merging some code blocks based on the number of calls or the calling frequency of the common code blocks.

9. A system for optimizing code of an application, comprising: One or more memories storing executable instructions; as well as One or more processors execute the executable instructions to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for accelerating operating speed of graphics processing unit (GPU) through dead code removal

    CN103049304A

  • Method and device for dynamically burying points and electronic device

    CN107436832A