Processing method and device of application program and electronic equipment
Patent Information
- Application Number
- CN202110407836.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-15
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2041-04-15
AI Technical Summary
然而,这种方法的处理效率低,且定位后的修复周期长
[0041]Thirdly, this disclosure provides an electronic device, including: a memory and a processor; the memory is used to store program instructions; the processor is used to invoke the program instructions in the memory to cause the electronic device to execute the processing method of the application program in the first aspect and any possible design of the first aspect.
Smart Images

Figure CN115220725B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of Internet technology, and more particularly to a method, apparatus, and electronic device for processing an application. Background Technology
[0002] During the development, operation, and upgrade of software applications on the Android system, as the business expands and updates, developers can write new code corresponding to the business and optimize the new code.
[0003] However, as new code corresponding to the business logic is merged in, the application's target path (such as the startup path) may deteriorate, potentially rendering all optimization work by developers futile. Therefore, methods to prevent application degradation are crucial.
[0004] Currently, the existing methods for preventing application degradation include the following two:
[0005] 1. Before release, compare the merged and unmerged versions of the application offline to test for any degradation in metrics. However, this method, because it is done before release, cannot promptly intercept degradation even if it occurs in the merged version, and can only rely on subsequent versions for fixes.
[0006] Second, after release, observe the merged version of the program online to determine if any metrics have degraded. If degradation is found in the merged version, locate the degradation point and analyze the cause. However, this method is inefficient and the repair cycle after location is long. Summary of the Invention
[0007] In order to solve the above-mentioned technical problems, or at least partially solve the above-mentioned technical problems, this disclosure provides a method, apparatus and electronic device for processing applications.
[0008] In a first aspect, this disclosure provides a method for processing an application, including:
[0009] Receive the merge code from the application;
[0010] Determine whether the modified code in the merged code involves the application's target path;
[0011] Determine if the modified code contains time-consuming operations;
[0012] When the code in the modified section involves the target path and has time-consuming operations, the analysis results are output. The analysis results include the target code in the merged code that involves the target path and has time-consuming operations, as well as the target location of the corresponding code.
[0013] Using the method provided in the first aspect, after the application's merged code is submitted, the modified parts of the merged code are analyzed. First, the analysis checks whether the modified code involves the target path; second, it analyzes whether the modified code contains time-consuming operations. If the modified code involves the target path and contains time-consuming operations, the analysis results can be notified to the code reviewers. The analysis results include the target code in the merged code that involves the target path and contains time-consuming operations, as well as the location of the target code. This allows the code reviewers to conduct a code review with the developers, so that the merged code can be merged into the repository after a successful review, or the code reviewers can prevent the merged code from being merged into the repository. This allows for earlier detection of whether the merged code will cause application degradation on the target path, providing sufficient time to fix the merged code, improving the efficiency of application degradation prevention, and shortening the application's repair cycle. In one possible design, determining whether the modified code contains time-consuming operations includes: if it is determined that the modified code involves the target path, then determining whether the code in the modified code involving the target path contains time-consuming operations.
[0014] In one possible design, determining whether the code in the modified portion of the merged code involves the application's target path includes: obtaining a target file that records all functions in the application's entire code that involve the target path; and based on the target file, determining whether the code in the modified portion involves the target path.
[0015] In one possible design, based on the target file, determining whether the code in the modified section involves the target path includes: if the code in the modified section is contained in a function recorded in the target file, determining that the code in the modified section involves the target path; if the code in the modified section is not contained in a function recorded in the target file, determining that the code in the modified section does not involve the target path.
[0016] In one possible design, obtaining the target file includes: obtaining a first file and determining, based on the first file, a first set of functions called in the target path from the entire code of the application; obtaining a second file and determining, based on the second file, a second set of functions called in the root function of the target path from the entire code of the application; and determining the target file as the union of the first set of functions and the second set of functions.
[0017] In one possible design, the method further includes: determining a first file. Determining the first file includes: configuring the start and end functions of the target path during the application's compilation phase; instrumenting all code in the application; based on the instrumentation, recording the called functions between the start and end functions in the first file during the application's runtime phase; and saving the first file.
[0018] In one possible design, the method further includes: determining a second file. Determining the second file includes: identifying the root function of the target path; compiling all application code into first bytecode; performing static analysis on the first bytecode to obtain the sub-functions directly and indirectly called by the root function, and recording the root function and sub-functions in the second file; and saving the second file.
[0019] In one possible design, determining whether the modified code contains time-consuming operations includes: during the application's compilation phase, compiling the modified code into second bytecode; for each function in the second bytecode, determining whether the type of each function is within a pre-defined list of types, which records the types of time-consuming functions; if the type of a function in the second bytecode is within the pre-defined list of types, determining that a function corresponds to a time-consuming operation in the modified code; if the type of a function in the second bytecode is not within the pre-defined list of types, determining that a function corresponds to a time-consuming operation in the modified code.
[0020] In one possible design, when a function in the second bytecode calls an external function, and all functions in the second bytecode do not include the external function called by the function, the method further includes: determining whether the type of the external function called by the function is within the type range of a preset list; if the external function called by the function is within the type range of the preset list, determining that the function has a time-consuming operation; if the external function called by the function is not within the type range of the preset list, determining that the function does not have a time-consuming operation.
[0021] In one possible design, when it is determined that a function in the second bytecode has a time-consuming operation and involves the target path, the function is identified as the target code, the position of the function is identified as the position of the target code, and the target code and the position of the target code are saved to the analysis results.
[0022] In one possible design, the types of time-consuming functions in the preset list include: locking functions, JSON parsing functions, read / write I / O functions, and system time-consuming functions.
[0023] In one possible design, the target path is the main thread of the main process in the application's startup path.
[0024] Secondly, this disclosure provides an application processing apparatus, comprising:
[0025] The receiving module is used to receive the merge code from the application.
[0026] The determination module is used to determine whether the code in the modified portion of the merged code involves the target path of the application.
[0027] The module is also used to determine whether there are time-consuming operations in the modified code.
[0028] The output module is used to output analysis results when the code in the modified part involves the target path and has time-consuming operations. The analysis results include the target code in the merged code that involves the target path and has time-consuming operations, as well as the location of the target code.
[0029] In one possible design, a determination module is specifically used to determine whether the code in the modified part that involves the target path has time-consuming operations after determining that the code in the modified part involves the target path.
[0030] In one possible design, a module is identified specifically for obtaining a target file containing all functions in the application's entire code that relate to the target path; based on the target file, it is determined whether the code in the modified section relates to the target path.
[0031] In one possible design, a module is defined to determine if the code in the modified section involves the target path when the code in the modified section is included in a function recorded in the target file; and to determine if the code in the modified section does not involve the target path when the code in the modified section is not included in a function recorded in the target file.
[0032] In one possible design, a determination module is used to obtain a first file and, based on the first file, determine a first set of functions in the entire code of the application that are called in the target path; obtain a second file and, based on the second file, determine a second set of functions in the entire code of the application that are called in the root function of the target path; and determine the target file as the union of the first set of functions and the second set of functions.
[0033] In one possible design, the determining module is also used to determine the first file. Specifically, the determining module is used during the application's compilation phase to configure the start and end functions of the target path; to instrument all the application's code; based on the instrumentation, during the application's runtime phase, to record the called functions between the start and end functions in the first file; and to save the first file.
[0034] In one possible design, the determining module is also used to determine the second file. Specifically, the determining module is used to determine the root function of the target path; compile all application code into first bytecode; perform static analysis on the first bytecode to obtain the sub-functions directly and indirectly called by the root function, and record the root function and its sub-functions in the second file; and save the second file.
[0035] In one possible design, the module is further specifically used during the application's compilation phase to compile the modified portion into second bytecode; for each function in the second bytecode, it is determined whether the type of each function is within the range of a preset list of types, which records the types of time-consuming functions; when the type of a function in the second bytecode is within the range of types in the preset list, it is determined that a function corresponds to a time-consuming operation in the modified portion of the code; when the type of a function in the second bytecode is not within the range of types in the preset list, it is determined that a function corresponds to a time-consuming operation in the modified portion of the code.
[0036] In one possible design, the determining module is further configured to: determine whether the type of the external function called by a function is within the range of a preset list of types when a function corresponding to a function in the second bytecode has an external function called, and all functions corresponding to the second bytecode do not include the external function called by a function; determine whether a function has a time-consuming operation when the external function called by a function is within the range of types in the preset list; and determine whether a function does not have a time-consuming operation when the external function called by a function is not within the range of types in the preset list.
[0037] In one possible design, when it is determined that a function in the second bytecode has a time-consuming operation and involves the target path, the function is identified as the target code, the position of the function is identified as the position of the target code, and the target code and the position of the target code are saved to the analysis results.
[0038] In one possible design, the types of time-consuming functions in the preset list include: locked functions, JSON parsing functions, read / write I / O functions, and system time-consuming functions.
[0039] In one possible design, the target path is the main thread of the main process in the application's startup path.
[0040] The beneficial effects of the application processing apparatus provided in the second aspect and the various possible designs of the second aspect can be seen in the beneficial effects of the first aspect and the various possible implementations of the first aspect, and will not be repeated here.
[0041] Thirdly, this disclosure provides an electronic device, including: a memory and a processor; the memory is used to store program instructions; the processor is used to invoke the program instructions in the memory to cause the electronic device to execute the processing method of the application program in the first aspect and any possible design of the first aspect.
[0042] Fourthly, this disclosure provides a computer storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform the processing method of the application program in the first aspect and any possible design of the first aspect.
[0043] Fifthly, this disclosure provides a computer program product that, when run on a computer, causes the computer to execute the processing method of the application program in the first aspect and any possible design of the first aspect. Attached Figure Description
[0044] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0045] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 A flowchart illustrating the processing method of the application provided in this embodiment of the disclosure;
[0047] Figure 2 A flowchart illustrating the processing method of the application provided in this embodiment of the disclosure;
[0048] Figure 3 A flowchart illustrating the processing method of the application provided in this embodiment of the disclosure;
[0049] Figure 4 A flowchart illustrating the processing method of the application provided in this embodiment of the disclosure;
[0050] Figure 5 A flowchart of the processing apparatus for the application provided in this disclosure embodiment;
[0051] Figure 6 A flowchart illustrating the processing method of the application provided in this embodiment of the disclosure;
[0052] Figure 7 A schematic diagram of the structure of the processing device for the application provided in the embodiments of this disclosure. Detailed Implementation
[0053] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0054] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0055] For example, this disclosure provides a method, apparatus, device, computer storage medium, and computer program product for processing an application. After the merged code of an application is submitted, the modified parts of the merged code are detected and analyzed. First, the modified code is analyzed to determine whether it involves a target path; second, the modified code is analyzed to determine whether it contains time-consuming operations. The analysis results are then communicated to code reviewers, who can determine subsequent actions to take based on the analysis results. If the modified code involves a target path and contains time-consuming operations, the analysis results can be communicated to code reviewers. These results include the target code in the merged code that involves the target path and contains time-consuming operations, as well as the location of the target code. This allows code reviewers to conduct code reviews with developers, enabling them to merge the merged code into the repository after a successful review, or to prevent the merged code from being merged into the repository. This allows for earlier detection of whether merged code will cause application degradation at the target path, providing sufficient time to fix the merged code, improving the efficiency of application degradation prevention, and shortening the application repair cycle.
[0056] The application processing method disclosed herein is executed by a code management platform. The code management platform can be a server, a terminal device, or an application (APP), webpage, public account, etc. on the terminal device. This disclosure does not impose any restrictions on the specific type of code management platform.
[0057] Based on the foregoing description, this disclosure will use a code management platform as an example to illustrate the processing method of the application provided by this disclosure in detail, in conjunction with the accompanying drawings and application scenarios.
[0058] Please see Figure 1 , Figure 1 This is a flowchart illustrating the processing method of the application provided in an embodiment of this disclosure. Figure 1 As shown, the processing method of the application provided in this disclosure may include:
[0059] S101, Receive the merge code from the application.
[0060] The code management platform receives the merged code for the application from the developers. This merged code may include code corresponding to specific business logic. If the business logic is already present in the application, the merged code may include the newly added code corresponding to that business logic; if the business logic is newly added to the application, the merged code may include the code corresponding to that newly added business logic.
[0061] In addition to the code corresponding to the business logic, the merged code may also include other code from the application. Furthermore, this disclosure does not limit the type of application or the specific representation of the merged code.
[0062] In addition to the merged code, the code management platform may also receive an identifier indicating that the developer wants to merge the code into the application, so that the code management platform can detect the merged code. Furthermore, this disclosure does not limit the specific representation of this identifier.
[0063] S102. Determine whether the code in the modified part of the merged code involves the target path of the application.
[0064] After the merged code is committed, the code management platform can detect whether the modifications in the merged code involve the application's target path, in order to avoid the application's target path from being degraded.
[0065] When the code in the modified section does not involve the target path, the code management platform can notify the code reviewers to merge the code into the repository.
[0066] The target path can be the stage corresponding to the application's implementation of one or more business functions, one or more scenarios, or one or more features. This disclosure does not limit the specific implementation method of the target path.
[0067] In some embodiments, the target path is the main thread of the main process in the application's startup path. The startup path is the time period from application startup to the display of a preset initial page. Specifically, when the startup path is set from application startup to the display of the main page, the main thread of the main process is used to implement this process. Similarly, when the startup path is set from application startup to the display of the first page (such as a referral page), the main thread of the main process is used to implement this process.
[0068] S103. Determine if there are time-consuming operations in the code of the modified section.
[0069] After the application's merged code is committed, the code management platform can detect whether there are time-consuming operations in the modified code. This disclosure does not limit the method by which the code management platform determines whether there are time-consuming operations in the modified code.
[0070] If there are no time-consuming operations in the code that need to be modified, the code management platform can notify the code reviewers to merge the code into the repository.
[0071] It should be noted that the execution order of steps S102 and S103 is not important.
[0072] Step S102 can be performed before step S103. That is, after modifying the part involving the target path, it is then determined whether the code in the modified part involving the target path has time-consuming operations. Thus, the code management platform only needs to analyze whether the code in the modified part involving the target path has time-consuming operations, without having to analyze all the code in the modified part, reducing workload and improving work efficiency.
[0073] Step S103 can also be performed before step S102. That is, after the code in the modified section contains time-consuming operations, it is determined whether the code in the modified section containing time-consuming operations involves the target path. Thus, the code management platform only needs to analyze whether the code in the modified section containing time-consuming operations involves the target path, without having to analyze all the code in the modified section, reducing workload and improving work efficiency.
[0074] Step S102 can also be executed simultaneously with step S103, that is, simultaneously determining the code 1 in the modified part that has time-consuming operations, and the code 2 in the modified part that involves the target path, and then determining whether the aforementioned code 1 and the aforementioned code 2 have any intersection. Thus, the determination time is saved and the work efficiency is improved.
[0075] In addition, before the code management platform executes step S102 or step S103, it needs to determine whether there are modified parts in the merged code.
[0076] S104. When the code in the modified section involves the target path and has time-consuming operations, output the analysis results. The analysis results include the target code in the merged code that involves the target path and has time-consuming operations, as well as the location of the target code.
[0077] Based on the descriptions of steps S102 and S103, the code management platform can determine whether the modified part involves the target path and whether there are time-consuming operations in the modified part, so that the code management platform can notify the code reviewers whether the modified part involves the target path and whether there are time-consuming operations.
[0078] Therefore, when the code in the modified part involves the target path and has time-consuming operations, the code management platform can output analysis results so as to notify the code reviewers that the merged code includes target code that involves the target path and has time-consuming operations, as well as the location of the target code.
[0079] This disclosure does not limit the specific representation of the analysis results. For example, the analysis results include an existence identifier and a location identifier. The existence identifier indicates that the merged code includes code that involves the target path and has time-consuming operations, and the location identifier indicates the position of the corresponding code. The aforementioned identifiers can be represented in the form of numbers, letters, characters, etc.
[0080] The application processing method disclosed herein analyzes and detects the modified parts of the merged code after the application's merged code is submitted. This analysis includes two aspects: first, whether the modified code involves the target path; and second, whether the modified code contains time-consuming operations. If the modified code involves the target path and contains time-consuming operations, the analysis results can be notified to the code reviewers. These results include the target code within the merged code that involves the target path and contains time-consuming operations, along with the location of the target code. This allows the code reviewers to conduct a code review with the developers, enabling them to merge the code into the repository after a successful review, or to prevent the merge from being included in the repository. This allows for earlier detection of whether merged code will cause application degradation at the target path, providing sufficient time to fix the merged code, improving the efficiency of application degradation prevention, and shortening the application's repair cycle.
[0081] based on Figure 1 In the description of the embodiment, in step S102, the code management platform uses a combination of dynamic and static analysis to obtain the time-consuming functions corresponding to the target path in all the code of the application.
[0082] In some embodiments, the code management platform may obtain a target file. This target file contains all functions in the application's code that relate to the application's target path. This disclosure does not limit the specific implementation of the target file. Furthermore, the functions mentioned in this disclosure can also be understood as methods or function methods.
[0083] Furthermore, the target file can be stored in the code management platform, on the server, or both, to fully consider the available storage space of the code management platform. This disclosure does not impose any limitations on this. For ease of explanation, this disclosure uses the storage of the target file in the code management platform as an example.
[0084] Since the code management platform can identify all functions in the entire application code that involve the target path based on the target file, and the code in the modified section can be instruction code or function call code, the code management platform can analyze whether the code in the modified section is included in the functions recorded in the target file to determine whether the code in the modified section involves the target path.
[0085] When the code in the modified section is contained within a function recorded in the target file, the code management platform can determine that the code in the modified section involves the target path.
[0086] If the code in the modified section is not included in the functions recorded in the target file, the code management platform can determine that the code in the modified section does not involve the target path. In this case, the code management platform can notify the code reviewers to merge the code into the repository.
[0087] In one specific embodiment, assuming the target path is the startup path, based on Figure 1 In conjunction with the description of the above embodiments, Figure 2 The code management platform is introduced. Figure 1 One feasible way of processing the application in the embodiment.
[0088] like Figure 2 As shown, the code management platform can perform the following steps:
[0089] Step 01: Developers submit a merge request (MR) to the code management platform, corresponding to... Figure 1 Step 101 in the process. The MR code is the merge code for the application.
[0090] Step 02: After the code management platform enters the detection process, it retrieves the target file from the server and, based on the target file, determines whether the modified parts of the MR code involve the startup path, corresponding to... Figure 1 Step 102 in the process.
[0091] Step 03: When the code in the modified section of the MR code involves the startup path, the code management platform determines whether there are time-consuming operations in the modified code, corresponding to... Figure 1 Step 103 in the process.
[0092] Step 04: When the code management platform detects time-consuming operations in the modified code, it outputs the analysis results, corresponding to... Figure 1 Step 103 in the process.
[0093] Therefore, the code management platform can proceed to the review stage and notify the code reviewers of the analysis results, enabling them to determine whether the MapReduce (MR) code can pass the review. Once the MR code passes the review, the code management platform can proceed to the repository ingestion process to store the MR code in the repository.
[0094] In addition, if the code in the modification section of the code management platform does not involve the startup path, or if the code in the modification section does not involve time-consuming operations, it can proceed to the database entry process.
[0095] In this disclosure, the code management platform can obtain the target file in multiple ways. The target file can be divided into a first file and a second file. Both the first and second files record all functions in the application's entire code that relate to the target path. Furthermore, the first and second files determine the total number of functions in the application's entire code that relate to the target path from different perspectives.
[0096] Below, in conjunction with Figure 3 When the target file is stored in the local storage module of the code management platform, this paper introduces the specific implementation method of the code management platform to obtain the target file.
[0097] Please see Figure 3 , Figure 3 This is a flowchart illustrating the processing method of the application provided in an embodiment of this disclosure. Figure 3 As shown, the processing method of the application provided in this disclosure may include:
[0098] S201. Obtain the first file and, based on the first file, determine the first set of functions that are called in the target path in the entire code of the application.
[0099] In this disclosure, the first file records all functions in the application's code from the perspective of whether they are called in the target path. Therefore, the code management platform can obtain the first file from its local storage module and determine the first set of functions called in the target path from the application's entire code based on the first file.
[0100] This disclosure does not limit the method for determining the first document. In some embodiments, such as Figure 4 As shown, the steps for determining the first file may include:
[0101] Step 11: During the application's compilation phase, configure the start and end functions for the target path.
[0102] The start function initiates the target path, and the stop function terminates the target path. This disclosure does not limit the specific implementation methods of the target path, start function, and stop function.
[0103] Step 12: Instrument all code in the application.
[0104] This disclosure does not limit the specific implementation of instrumentation. In some embodiments, during the compilation of the application, "stub functions" are inserted into the "exit" and "entry" points of all functions in the entire code of the application.
[0105] Step 13: Based on instrumentation, during the application's runtime phase, the called functions between the start function and the end function are recorded in the first file.
[0106] The code management platform can automatically launch the application to collect all called functions in the application's code. For example, if the target path is the main thread of the application's main program, then all called functions in the application's code are those started by the main thread of the main process.
[0107] During application runtime, if a function is called within the target path, a "stub function" records that function. Recording stops once the target path ends. That is, after the first execution of a terminating function, the collection of called functions merged into the code within the target path ceases. Thus, the code management platform can save all recorded functions in a first file.
[0108] Step 14: Save the first file. Specifically, the first file can be saved locally first, and then sent to the server.
[0109] Thus, the code management platform can dynamically collect the first set of functions corresponding to the target path in all the code of the application.
[0110] It should be noted that, Figure 4 In the embodiments, the step of determining the first file can be performed by the code management platform or by other execution platforms, and this disclosure does not limit this.
[0111] S202. Obtain the second file and, based on the second file, determine the set of second functions that are called in the root function of the target path in the entire code of the application.
[0112] In this disclosure, the second file records all functions in the application's code from the perspective of whether they are called in the root function of the target path. Therefore, the code management platform can obtain the second file from its local storage module and determine the set of second functions called in the root function of the target path within the code management platform based on the second file.
[0113] This disclosure does not limit the method for determining the second document. In some embodiments, such as Figure 5 As shown, the steps for determining the second file may include:
[0114] Step 21: Determine the root function of the target path.
[0115] This disclosure does not limit the specific implementation of the root function of the target path. For example, when the target path is the startup path, the root function of the target path can be configured as the lifecycle functions of the four major Android components (activity, service, content provider, and broadcast receiver) and the application startup. In addition, the root function of the target path can be pre-configured in the code management platform, and there is no need to configure it again here.
[0116] Step 22: Compile all the application code into first bytecode.
[0117] Step 23: Perform static analysis on the first bytecode to obtain the sub-functions directly and indirectly called by the root function, and record the root function and sub-functions in the second file.
[0118] The code management platform can employ static bytecode analysis to determine the call paths of corresponding functions in the first bytecode. It then uses a reachability algorithm, such as an optimized MainDexList, to analyze the direct and indirect calls of the root function's sub-functions to identify all linked functions (i.e., the root function and its sub-functions). The code management platform can then record all collected linked functions in a second file.
[0119] Step 24: Save the second file. Specifically, the second file can be saved locally first, and then sent to the server.
[0120] Thus, the code management platform can achieve static collection of the second set of functions called in the root function of the target path in the entire code of the application.
[0121] It should be noted that, Figure 5 In addition to being executed by the code management platform, the step of determining the second file in the embodiments can also be executed by other execution platforms, and this disclosure does not limit this.
[0122] S203. Determine the target file as the union of the first function set and the second function set.
[0123] Because both the first and second function sets may miss some functions in the target path—for example, the first function set cannot cover all if-else code branches, and the second function set cannot cover indirect method call cases (such as Action, event, etc.)—the code management platform can take the union of the first and second function sets as the target file to cover the target path as comprehensively as possible.
[0124] In summary, the code management platform can obtain the target file from the local storage module of the code management platform.
[0125] It should be noted that, in addition to the above implementation methods, the code management platform can also obtain the target file from the server, or it can obtain the first file and the second file from the server respectively. This disclosure is not limited to the above implementation methods.
[0126] Based on the above Figures 3-5 As described in the embodiment, the code management platform can collect target files obtained based on the dynamic and static combination strategy as comprehensively as possible, so as to be able to analyze the functions involved in the target path as completely as possible, thereby determining whether the modified parts in the merged code involve the target path to the greatest extent based on the target files.
[0127] In this disclosure, the code management platform can adopt various implementation methods to determine whether there are time-consuming operations in the code of the modification part in step S104.
[0128] Below, in conjunction with Figure 6 This paper introduces a feasible approach for code management platforms to determine whether time-consuming operations exist in the modified code.
[0129] Please see Figure 6 , Figure 6 This is a flowchart illustrating the processing method of the application provided in an embodiment of this disclosure. Figure 6 As shown, the processing method of the application provided in this disclosure may include:
[0130] S301. During the compilation phase of the application, the modified parts are compiled into second bytecode.
[0131] Because the code management platform can execute bytecode, during the application's compilation phase, it can compile the modified parts into second bytecode. This allows the platform to statically analyze the bytecode to determine if the modified code corresponding to the function in the bytecode contains time-consuming operations.
[0132] For example, if the code in the modified section uses Java source code, the code management platform can compile the Java source code into second bytecode that the code management platform can execute, so as to determine whether the corresponding function is time-consuming by statically analyzing the instructions corresponding to the bytecode.
[0133] S302. For each function in the second bytecode, determine whether the type of each function is within the type range of the preset list, which records the types of time-consuming functions.
[0134] Because the preset list records the types of time-consuming functions, for a function corresponding to the second bytecode, during the execution phase of the target path, the code management platform can determine whether a function type is within the range of types in the preset list, thereby determining whether the code corresponding to that function in the modified part contains time-consuming operations.
[0135] The preset list can be pre-configured in the code management platform or entered by developers into the code management platform; this disclosure does not limit this.
[0136] Furthermore, this disclosure does not limit the specific implementation of the preset list and the time-consuming function.
[0137] In some embodiments, the types of time-consuming functions in the preset list may include, but are not limited to: locked functions, JSON parsing functions, read / write I / O functions, and system time-consuming functions (e.g., if the application's function fun1 calls a time-consuming function aFun1 in the Android SDK, then function fun1 is a time-consuming function). Additionally, the types of time-consuming functions in the preset list may also include loop functions.
[0138] When the type of a function corresponding to the second bytecode is within the range of types in the preset list, the code management platform can execute step S3031; when the type of a function corresponding to the second bytecode is not within the range of types in the preset list, the code management platform can execute step S3032.
[0139] S3031. Determine that a function in the second bytecode corresponds to a time-consuming operation in the modified part of the code.
[0140] When the type of a function in the second bytecode is within the range of the preset list, the code management platform can determine that the function corresponds to a time-consuming operation in the modified code.
[0141] S3032. Determine that the function in the second bytecode corresponds to a code in the modified section that does not involve time-consuming operations.
[0142] When the type of a function in the second bytecode is not within the range of the preset list, the code management platform can determine that the code corresponding to that function in the modified part does not involve time-consuming operations.
[0143] In summary, the code management platform can determine whether there are time-consuming operations in the modified code based on all the corresponding functions in the second bytecode.
[0144] Therefore, static analysis can determine whether there are time-consuming operations in the modified code.
[0145] In addition, based on the above description, the code management platform can adhere to the principle that "function time consumption is transitive" to determine whether there are time-consuming operations in the modified code.
[0146] Furthermore, because the modified code may call functions that already exist in previous versions of the application, and the modified code does not include the code for those called functions, the corresponding functions in the second bytecode may not include the called functions.
[0147] Therefore, for a function in the second bytecode, if this function calls an external function, and all functions in the second bytecode do not include the external function called by this function, the code management platform can determine whether the type of the external second function called by this function is within the type range of a preset list, in order to determine whether the function has a time-consuming operation. This is beneficial for comprehensively identifying time-consuming functions in the modified code.
[0148] When the external function called by the function is within the type range of the preset list, the code management platform can determine that the function corresponds to a time-consuming operation in the modified part of the code.
[0149] When the external function called by the function is not within the type range of the preset list, the code management platform can determine that the code in the modified part corresponding to the function does not have time-consuming operations.
[0150] In other embodiments, the code in the modified section is itself a function (referred to as the first function), and the first function calls the second function. That is, the second function is a subfunction of the first function, and the first function is the parent function of the second function. Therefore, the code management platform can also determine whether the first function involves time-consuming operations by determining whether the type of the second function is within the range of a preset list of types.
[0151] Therefore, if the second function falls within the type range of the preset list, the code management platform can determine that the first function involves a time-consuming operation. If the second function does not fall within the type range of the preset list, the code management platform can determine that the first function does not involve a time-consuming operation.
[0152] For example, suppose the call relationship of three functions is function fun1 -> function fun2 -> function fun3, meaning function fun1 calls function fun2, and function fun2 calls function fun3. If function fun1 and function fun2 are not time-consuming functions, but function fun3 is a time-consuming function, then the code management platform can determine that functions fun1, fun2, and fun3 are all time-consuming functions, and that all three functions correspond to time-consuming operations in the modified code.
[0153] In summary, when it is determined that a function in the second bytecode contains a time-consuming operation and involves a target path, the code management platform can identify the function as the target code, determine the location of the function as the location of the target code, and save the target code and its location to the analysis results.
[0154] By way of example, this disclosure provides an application processing apparatus.
[0155] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of the application processing device provided in the embodiments of this disclosure. The application processing device of this disclosure can be installed in a code management platform and can realize the above-mentioned... Figures 1-6 The application processing method in this embodiment corresponds to the operation of the code management platform.
[0156] like Figure 7 As shown, the processing device 100 for the application provided in this disclosure may include: a receiving module 101, a determining module 102, and an output module 103.
[0157] The receiving module 101 is used to receive the merge code of the application.
[0158] Module 102 is used to determine whether the code in the modified part of the merged code involves the target path of the application.
[0159] The determination module 102 is also used to determine whether there are time-consuming operations in the code of the modified part;
[0160] The output module 103 is used to output analysis results when the code in the modified part involves the target path and has time-consuming operations. The analysis results include the target code in the merged code that involves the target path and has time-consuming operations, as well as the location of the target code.
[0161] In one possible design, module 102 is specifically used to determine whether the code in the modified part involving the target path involves time-consuming operations after determining that the code in the modified part involves the target path.
[0162] In some embodiments, the determining module 102 is specifically used to obtain a target file, which records all functions in the application's code that involve the target path; based on the target file, it determines whether the code in the modified part involves the target path.
[0163] In some embodiments, the determining module 102 is configured to determine that the code in the modified portion involves a target path when the code in the modified portion is included in a function recorded in the target file; and to determine that the code in the modified portion does not involve a target path when the code in the modified portion is not included in a function recorded in the target file.
[0164] In some embodiments, the determining module 102 is configured to acquire a first file and, based on the first file, determine a first set of functions called in the target path from the entire code of the application; acquire a second file and, based on the second file, determine a second set of functions called in the root function of the target path from the entire code of the application; and determine the target file as the union of the first set of functions and the second set of functions.
[0165] In some embodiments, the determining module 102 is further configured to determine a first file. Specifically, the determining module 102 is configured to configure the start function and the end function of the target path during the compilation phase of the application; perform instrumentation on all code of the application; based on the instrumentation, record the called functions between the start function and the end function in the first file during the runtime phase of the application; and save the first file.
[0166] In some embodiments, the determining module 102 is further configured to determine a second file. Specifically, the determining module 102 is configured to determine the root function of the configuration target path; compile all the application code into first bytecode; perform static analysis on the first bytecode to obtain the sub-functions directly and indirectly called by the root function, and record the root function and sub-functions in the second file; and save the second file.
[0167] In some embodiments, the determining module 102 is further configured to, during the compilation phase of the application, compile the modified portion into second bytecode; for each function corresponding to the second bytecode, during the runtime phase of the target path, determine whether the type of each function is within the type range of a preset list, the preset list recording the types of time-consuming functions; when the type of a function corresponding to the second bytecode is within the type range of the preset list, determine that a function corresponds to a time-consuming operation in the modified portion of the code; when the type of a function corresponding to the second bytecode is not within the type range of the preset list, determine that a function corresponds to a time-consuming operation in the modified portion of the code.
[0168] In some embodiments, the determining module 102 is further configured to: determine whether the type of the external function called by a function is within the range of types in a preset list when a function corresponding to a function in the second bytecode has an external function called, and all functions corresponding to the second bytecode do not include the external function called by a function; determine whether a function has a time-consuming operation when the external function called by a function is within the range of types in the preset list; and determine whether a function does not have a time-consuming operation when the external function called by a function is not within the range of types in the preset list.
[0169] In one possible design, when it is determined that a function in the second bytecode has a time-consuming operation and involves the target path, the function is identified as the target code, the position of the function is identified as the position of the target code, and the target code and the position of the target code are saved to the analysis results.
[0170] In some embodiments, the types of time-consuming functions in the preset list include: locked functions, JSON parsing functions, read / write I / O functions, and system time-consuming functions.
[0171] In some embodiments, the target path is the main thread of the main process in the application's startup path.
[0172] The processing device of the application provided in this disclosure can execute the above method embodiments. The specific implementation principle and technical effect can be found in the above method embodiments, and will not be repeated here.
[0173] For example, this disclosure provides an electronic device including: one or more processors; a memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; and when the one or more processors execute the one or more computer programs, the electronic device causes the electronic device to implement the processing method of the application described in the foregoing embodiments.
[0174] For example, this disclosure provides a chip system applied to an electronic device including a memory and a sensor; the chip system includes: a processor; and a processing method for the application program described in the preceding embodiments when the processor executes the application program.
[0175] For example, this disclosure provides a computer-readable storage medium having a computer program stored thereon, the computer program being processed by a processor to cause an electronic device to execute the processing method of the application program described in the preceding embodiments.
[0176] For example, this disclosure provides a computer program product that, when run on a computer, causes the computer to execute the application processing method described in the preceding embodiments.
[0177] In the above embodiments, all or part of the functionality can be implemented by software, hardware, or a combination of software and hardware. When implemented using software, it can be implemented wholly or partially in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this disclosure is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0178] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0179] The above are merely specific embodiments of this disclosure, enabling those skilled in the art to understand or implement this disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to these embodiments, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for processing an application, characterized in that, include: Receive the merge code from the application; Determine whether the modified portion of the merged code is included in functions recorded in the target file, in order to determine whether the modified portion of the merged code involves the target path of the application; wherein, the target file records all functions in the entire code of the application that involve the target path, and the target path is the main thread of the main process in the startup path of the application; The modified code is compiled into second bytecode. Based on whether the type of the function in the second bytecode is within the type range of a preset list, it is determined whether there is a time-consuming operation in the modified code. The preset list records the types of time-consuming functions. When the code in the modified section involves the target path and has a time-consuming operation, the analysis result is output. The analysis result includes the target code in the merged code that involves the target path and has a time-consuming operation, as well as the location of the target code.
2. The method according to claim 1, characterized in that, Determining whether the code in the modified section contains time-consuming operations includes: If it is determined that the code in the modified part involves the target path, then it is determined whether the code in the modified part involving the target path involves a time-consuming operation.
3. The method according to claim 1 or 2, characterized in that, Determining whether the modified portion of the merged code involves the target path of the application includes: Obtain the target file; When the code in the modified portion is included in a function recorded in the target file, it is determined that the code in the modified portion relates to the target path; If the code in the modified section is not included in the function recorded in the target file, it is determined that the code in the modified section does not involve the target path.
4. The method according to claim 3, characterized in that, The acquisition of the target file includes: Obtain a first file, and based on the first file, determine a first set of functions that are called in the target path from the entire code of the application; Obtain the second file, and based on the second file, determine the set of second functions that are called in the root function of the target path in the entire code of the application; The target file is determined by the union of the first set of functions and the second set of functions.
5. The method according to claim 4, characterized in that, The method further includes: determining the first file; determining the first file includes: During the compilation phase of the application, the start and end functions of the target path are configured; Instrument the entire code of the application. Based on the instrumentation process, during the runtime phase of the application, the functions called between the start function and the end function are recorded in the first file; Save the first file.
6. The method according to claim 4, characterized in that, The method further includes: determining the second file; determining the second file includes: Determine the root function of the target path; Compile all the code of the application into first bytecode; Static analysis is performed on the first bytecode to obtain the sub-functions directly and indirectly called by the root function, and the root function and the sub-functions are recorded in the second file; Save the second file.
7. The method according to claim 1, characterized in that, Determining whether the code in the modified section contains time-consuming operations includes: During the compilation phase of the application, the modified portion is compiled into second bytecode; For each function in the second bytecode, determine whether the type of each function is within the range of the preset list of types; When the type of a function corresponding to the second bytecode is within the type range of the preset list, it is determined that the function corresponds to a time-consuming operation in the modified part of the code. If a function type in the second bytecode is not within the range of types in the preset list, it is determined that the function corresponds to a time-consuming operation in the modified part.
8. The method according to claim 7, characterized in that, When a function in the second bytecode calls an external function, and all functions in the second bytecode do not include the external function, the method further includes: Determine whether the type of the external function is within the type range of the preset list; When the external function is within the type range of the preset list, it is determined that one of the functions has a time-consuming operation; When the external function is not within the type range of the preset list, it is determined that the function does not have a time-consuming operation.
9. The method according to claim 7, characterized in that, When it is determined that a function in the second bytecode has a time-consuming operation and involves the target path, the function is identified as the target code, the position of the function is identified as the position of the target code, and the target code and the position of the target code are saved to the analysis result.
10. The method according to any one of claims 7-9, characterized in that, The types of time-consuming functions in the preset list include: locking functions, JSON parsing functions, read / write I / O functions, and system time-consuming functions.
11. A processing apparatus for an application, characterized in that, include: The receiving module is used to receive the merge code from the application. A determining module is used to determine whether the code in the modified part of the merged code is included in the functions recorded in the target file, so as to determine whether the code in the modified part of the merged code involves the target path of the application; wherein, the target file records all functions in the entire code of the application that involve the target path, and the target path is the main thread of the main process in the startup path of the application; The determining module is further configured to compile the modified code into second bytecode, and determine whether the modified code contains time-consuming operations based on whether the type of the function in the second bytecode is within the type range of a preset list; wherein, the preset list records the types of time-consuming functions; An output module is used to output analysis results when the code in the modified part involves the target path and has time-consuming operations. The analysis results include the target code in the merged code that involves the target path and has time-consuming operations, as well as the location of the target code.
12. An electronic device, comprising: One or more processors; Memory; And one or more computer programs; wherein the one or more computer programs are stored in the memory; characterized in that, when the one or more processors execute the one or more computer programs, the electronic device causes the electronic device to implement the processing method of the application program as described in any one of claims 1-10.
13. A computer storage medium, characterized in that, Includes computer instructions that, when executed on an electronic device, cause the electronic device to perform a processing method of an application as described in any one of claims 1-10.
14. A computer program product, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the processing method of the application as described in any one of claims 1-10.
Citation Information
Patent Citations
Method and device for detecting covering rate and equipment
CN106294183A
Method and device for locating function performance problem
CN106909431A