A performance evaluation method and system for mobile applications
By analyzing the program calling diagram of the mobile application, the peaceful line function, identifying and evaluating the redundant code segment, solving the problem of inconsistent redundant code identification and evaluation in existing technology, and improving the accuracy of mobile application performance evaluation.
Patent Information
- Application Number
- CN202411412622.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-11
AI Technical Summary
The prior art fails to accurately identify and evaluate redundant code in mobile applications, resulting in poor accuracy in performance evaluation.
By obtaining a program call diagram for mobile applications, the parallel function is determined, and the redundant code segment is matched according to this information to calculate the code redundant to evaluate the application performance.
The accurate identification and evaluation of the redundant code situation of mobile applications has been realized, and the accuracy of mobile application performance assessment is improved.
Smart Images

Figure CN118939519B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a performance evaluation method and system for a mobile application. Background Art
[0002] Performance evaluation of mobile applications can directly affect user experience and the commercial value of applications. Users have higher and higher requirements for application performance. Performance evaluation can help developers understand the performance of applications in actual usage scenarios, including key indicators such as response time, throughput, and latency, so as to formulate effective optimization strategies. Therefore, it is very important to perform performance evaluation on mobile applications.
[0003] In existing methods, functional evaluations such as load testing, stress testing, and concurrency testing of mobile applications are usually performed based on automated testing tools.
[0004] However, it cannot identify redundant code situations in mobile applications, resulting in poor accuracy in mobile application performance evaluation. Summary of the invention
[0005] The embodiments of the present invention provide a method and system for evaluating the performance of a mobile application, which can improve the accuracy of the performance evaluation of the mobile application.
[0006] A first aspect of an embodiment of the present invention provides a performance evaluation method for a mobile application, comprising:
[0007] Obtaining a program call graph of the target mobile application, where the program call graph is used to represent the calling relationship between functions of the target mobile application;
[0008] Based on the program call graph, determine each parallel function in the target mobile application, where the parallel function is used to represent functions that implement the same function;
[0009] According to the program call graph and parallel functions, redundant code segments of the target mobile application are matched;
[0010] Determine the code redundancy of the target mobile application based on the redundant code segments;
[0011] The application performance of the target mobile application is evaluated based on the code redundancy.
[0012] According to a first aspect of an embodiment of the present invention, a performance evaluation system for a mobile application is provided, comprising:
[0013] A call graph acquisition module is used to acquire a program call graph of a target mobile application, where the program call graph is used to characterize the call relationship between functions of the target mobile application;
[0014] A function determination module, used to determine each parallel function in the target mobile application based on the program call graph, where the parallel function is used to represent functions that implement the same function;
[0015] A code segment matching module is used to match and obtain redundant code segments of a target mobile application according to a program call graph and parallel functions;
[0016] A redundancy determination module, used to determine the code redundancy of the target mobile application based on the redundant code segments;
[0017] The performance evaluation module is used to evaluate the application performance of the target mobile application according to the code redundancy.
[0018] In the performance evaluation method for mobile applications provided by an embodiment of the present invention, the program call graph of the target mobile application is first obtained, and then the parallel functions that implement the same function in the target mobile application are determined based on the program call graph. Then, based on the program call graph and the parallel functions, the redundant code segments of the target mobile application are determined. Thus, based on the redundant code segments, the code redundancy of the target mobile application is evaluated, and the performance of the mobile application is evaluated based on the redundant code situation of the mobile application. In this way, the embodiment of the present invention can accurately identify the redundant code situation of the mobile application through the program call graph of the target mobile application and the parallel functions in the target mobile application, thereby accurately evaluating the redundant code situation of the mobile application, and can improve the accuracy of the performance evaluation of the mobile application. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 A schematic diagram of a flow chart of a first mobile application performance evaluation method provided by an embodiment of the present invention;
[0021] Figure 2 A schematic flow chart of a second method for evaluating the performance of a mobile application provided by an embodiment of the present invention;
[0022] Figure 3 A schematic diagram of the structure of a subroutine call graph provided by an embodiment of the present invention;
[0023] Figure 4 A schematic flow chart of a third method for evaluating performance of a mobile application provided by an embodiment of the present invention;
[0024] Figure 5 A schematic flow chart of a fourth mobile application performance evaluation method provided by an embodiment of the present invention;
[0025] Figure 6 A schematic diagram of a first execution sequence of a first matching function provided by an embodiment of the present invention;
[0026] Figure 7 A schematic diagram of a second execution sequence of a second matching function provided by an embodiment of the present invention;
[0027] Figure 8 A schematic diagram of the structure of a mobile application performance evaluation system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of a performance evaluation method and system for a mobile application proposed by the present invention, its specific implementation method, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0029] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0030] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of the present invention are in compliance with the relevant provisions of laws and regulations.
[0031] It should be noted that in the embodiments of the present invention, certain software, components, models and other existing solutions in the industry may be mentioned, which should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present invention, but it does not mean that the applicant has or will necessarily use the solution.
[0032] In the existing methods, functional evaluations such as load testing, stress testing, and concurrency testing of mobile applications are usually performed based on automated testing tools. However, they cannot identify redundant code in mobile applications, resulting in poor accuracy in mobile application performance evaluation.
[0033] The purpose of the present invention is to provide a performance evaluation method and system for mobile applications. In the performance evaluation method for mobile applications provided by an embodiment of the present invention, the program call graph of the target mobile application is first obtained, and then the parallel functions that implement the same function in the target mobile application are determined based on the program call graph. Then, based on the program call graph and the parallel functions, the redundant code segments of the target mobile application are determined. Thus, based on the redundant code segments, the code redundancy of the target mobile application is evaluated, and the performance of the mobile application is evaluated based on the redundant code situation of the mobile application. In this way, the embodiment of the present invention can accurately identify the redundant code situation of the mobile application through the program call graph of the target mobile application and the parallel functions in the target mobile application, thereby accurately evaluating the redundant code situation of the mobile application, and improving the accuracy of the performance evaluation of the mobile application.
[0034] The following describes a specific embodiment of a performance evaluation method and system for a mobile application provided by an embodiment of the present invention.
[0035] Figure 1 A flow chart of a performance evaluation method for a mobile application is provided. The performance evaluation method for a mobile application can be applied to a server. The performance evaluation method for a mobile application can include the following S101 to S105.
[0036] S101, obtaining a program call graph of a target mobile application, where the program call graph is used to represent the calling relationship between functions of the target mobile application.
[0037] In this embodiment, the program call graph is a schematic diagram representing the upper and lower level call relationships between various function codes of the target mobile application.
[0038] As an example, the server can use a static code analysis tool (such as SonarQube or Checkmarx) to analyze the source code of the target mobile application, and then parse the source code to build a program call graph corresponding to the target mobile application.
[0039] S102, based on the program call graph, determining each parallel function in the target mobile application, where the parallel function is used to represent functions that implement the same function.
[0040] In this embodiment, parallel functions are redundant functions that implement the same or highly similar functions but may exist due to code copy and paste or unclear team division of labor.
[0041] As an example, the server can use a function similarity detection tool (such as Simian or PasteDetector) to automatically detect functions with high similarity in the program call graph and define them as parallel functions.
[0042] S103, matching and obtaining redundant code segments of the target mobile application according to the program call graph and the parallel functions.
[0043] In this embodiment, the redundant code segments are code segments that appear repeatedly in the target mobile application and have a high degree of similarity.
[0044] As an example, the server can use the program call graph to analyze the usage of each parallel function in the program and identify whether there are parallel functions that are frequently called to implement the same function. Then, for parallel functions that are repeatedly called in the call graph and have similar functions, the code segments that are called are marked as redundant code segments.
[0045] S104: Determine the code redundancy of the target mobile application based on the redundant code segments.
[0046] In this embodiment, the code redundancy is used to represent the proportion of redundant code segments in the target mobile application.
[0047] As an example, the server may count the proportion of all redundant code segments to the entire target mobile application code as a quantitative indicator of code redundancy.
[0048] S105, evaluating the application performance of the target mobile application according to the code redundancy.
[0049] In this embodiment, the server can preset the redundancy threshold of the target mobile application to 0.2. When the code redundancy of the target mobile application is greater than 0.2, it means that there are a large number of repeated functions and similar code segments in the current code of the target mobile application, and its application performance is low.
[0050] Furthermore, when the code redundancy of the target mobile application is greater than 0.2, the server can issue a prompt message to notify the technical staff to refactor the existing business logic code and formulate a reconstruction set based on the code dependencies; or merge similar functions and code segments into more general functions or modules to improve the readability and maintainability of the code; further optimize the data structure and algorithm to reduce memory consumption.
[0051] In the performance evaluation method for mobile applications provided in this embodiment, the program call graph of the target mobile application is first obtained, and then the parallel functions that implement the same function in the target mobile application are determined based on the program call graph. Then, based on the program call graph and the parallel functions, the redundant code segments of the target mobile application are determined. Thus, based on the redundant code segments, the code redundancy of the target mobile application is evaluated, and the performance of the mobile application is evaluated based on the redundant code situation of the mobile application. In this way, the embodiment of the present invention can accurately identify the redundant code situation of the mobile application through the program call graph of the target mobile application and the parallel functions in the target mobile application, thereby accurately evaluating the redundant code situation of the mobile application, and can improve the accuracy of the performance evaluation of the mobile application.
[0052] As an optional embodiment, Figure 2 As shown, S101 may specifically include the following S201-S203:
[0053] S201, obtaining a subroutine call graph corresponding to each test case of the target mobile application, where the subroutine call graph is used to represent the call relationship between functions corresponding to the test case;
[0054] S202, matching each subroutine call graph respectively to obtain overlapping functions in the subroutine call graph, where the overlapping functions are used to represent functions that appear in multiple subroutine call graphs;
[0055] S203, splicing the subroutine call graphs according to the overlapping functions to obtain the program call graph of the target mobile application.
[0056] In this embodiment, the subroutine call graph is used to characterize the calling relationship between the functions corresponding to the test case. Figure 3 As shown, a schematic diagram of the structure of a subroutine call graph is provided, wherein the nodes in the subroutine call graph represent functions, and the edges in the subroutine call graph represent the calling relationship of the functions.
[0057] As an example, the server first obtains each test case corresponding to the target mobile application. Then, it uses an automated testing tool (such as Appium or Espresso) to execute each test case, and then uses a dynamic analysis tool (such as Frida or Objection) to record the call of each function during the application execution process, thereby generating a subroutine call graph corresponding to the test case.
[0058] Then, the server loads the subroutine call graphs of all test cases, traverses the functions in each subroutine call graph, and compares them with the functions in other subroutine call graphs. Use data structures such as hash tables or sets to quickly find and match function names, and name repeated functions as overlapping functions.
[0059] Finally, the overlapping functions are added as nodes to the global call graph. Then the subroutine call graph of each test case is checked, and the function call paths in different test cases are merged into the global call graph with the overlapping functions as key nodes, so as to construct the program call graph of the target mobile application.
[0060] Through this embodiment, a program call graph of the target mobile application is constructed according to the subroutine call graphs corresponding to the test cases of the target mobile application. Therefore, the calling relationship between the functions of the target mobile application is accurately obtained according to the program call graph, which is helpful for determining the parallel functions and redundant code segments in the target mobile application according to the program call graph. Therefore, the redundant code situation of the mobile application is accurately evaluated, which can improve the accuracy of the performance evaluation of the mobile application.
[0061] As an optional embodiment, S201 may specifically include:
[0062] Obtaining test cases corresponding to the target mobile application;
[0063] Execute each test case separately and capture the function call sequence in each test case;
[0064] According to the function calling sequence in each test case, a subroutine calling graph corresponding to each test case is generated respectively.
[0065] In this embodiment, the server first performs a business requirements analysis on the target mobile application, and then designs test cases covering all key functions and boundary conditions based on the requirements analysis results.
[0066] Then, use an automated testing tool (such as Appium or Espresso) to execute each test case, and use the performance monitoring tool VisualVM to capture the function call sequence during the execution of each test case.
[0067] Finally, use graphical tools (such as Graphviz or Gephi) or programming libraries (such as networkx in Python) to create a subroutine call graph and map the function call sequence of the test case to nodes (functions) and edges (call relationships) in the subroutine call graph.
[0068] Through this embodiment, a corresponding subroutine call graph is generated for each test case of the target mobile application. The subroutine call graph can help understand the internal logic of the target mobile application and discover potential performance bottlenecks. This helps to accurately evaluate the redundant code of the mobile application and improve the accuracy of the performance evaluation of the mobile application.
[0069] As an optional embodiment, Figure 4As shown, S102 may specifically include the following S401-S405:
[0070] S401, obtaining function names of a first function and a second function in a program call graph, where the first function and the second function are any two functions selected from the program call graph;
[0071] S402, splitting the function names of the first function and the second function respectively to obtain function name text blocks corresponding to the first function and the second function respectively;
[0072] S403, determining a first similarity between the first function and the second function based on a function name text block corresponding to the first function and a function name text block corresponding to the second function;
[0073] S404, updating the first similarity according to the internal calling function of the first function and the internal calling function of the second function to obtain a second similarity between the first function and the second function;
[0074] S405: When the second similarity is greater than a preset similarity threshold, determine that the first function and the second function belong to the parallel function.
[0075] In this embodiment, the server can first add all function names in the program call graph to the function name set, and then select any two functions from the function name set as analysis objects. Specifically, for each function name identified from the program call graph, the server first determines whether it is in the function name set. If it is not in the function name set, it is added to the function name set; if it is in the function name set, there is no need to add it repeatedly.
[0076] Then, the server splits the function names of the first function and the second function in the analysis object according to the preset function name writing rules corresponding to the target mobile application, thereby obtaining function name text blocks corresponding to the first function and the second function, respectively. Specifically, the function names can be split using delimiters such as underscores or camel case naming method.
[0077] Then, the server can use a text similarity algorithm (such as Jaccard similarity or cosine similarity) to calculate the similarity between the two function name text block sets. Specifically, the number of common words in the two function name text block sets can be divided by the total number of words in the two function name text block sets, thereby obtaining the first similarity between the first function and the second function.
[0078] Furthermore, in order to more accurately determine whether two functions are parallel functions, their internal implementation needs to be considered, which means analyzing the functions they call. Specifically, the server can evaluate the impact of the internal call function of the first function and the internal call function of the second function on the first similarity through a graph-based structural similarity algorithm. Thus, the first similarity is updated according to the impact result to obtain the second similarity between the first function and the second function.
[0079] Finally, the second similarity is normalized, assuming that the preset similarity threshold is 0.9. When the second similarity between the first function and the second function is greater than or equal to 0.9, it is determined that the first function and the second function are parallel functions; when the second similarity between the first function and the second function is less than 0.9, it is determined that the first function and the second function are not parallel functions.
[0080] Through this embodiment, based on the similarity of the function name texts between the first function and the second function, it is possible to accurately determine whether the first function and the second function are parallel functions. This helps to subsequently identify redundant code segments in the target mobile application based on the parallel functions, and can accurately evaluate the redundant code situation of the mobile application.
[0081] As an optional embodiment, S403 may specifically include:
[0082] Based on a function name text block corresponding to a function and a function name text block corresponding to a second function, determining a first text block intersection and a first text block union between the first function and the second function;
[0083] The first text block intersection is divided by the first text block union to obtain a first similarity between the first function and the second function.
[0084] In this embodiment, the first similarity may be determined by the following formula 1:
[0085] Formula 1
[0086] In the formula, represents the first similarity between the u-th function and the v-th function. represents the first text block intersection between the u-th function and the v-th function, Represents the union of the first text block between the u-th function and the v-th function. Indicates the function name text block corresponding to the u-th function, Represents the function name text block corresponding to the vth function. represents the union operation, Represents the intersection operation.
[0087] in, Indicates the number of common text words between the function name text block corresponding to the u-th function and the function name text block corresponding to the v-th function, as a percentage of the total number of text words in the two function name text block sets. The larger the proportion, the greater the first similarity between the u-th function and the v-th function.
[0088] The first similarity between the uth function and the vth function The larger it is, the greater the possibility that the u-th function and the v-th function are parallel functions.
[0089] Through this embodiment, based on the function name text block corresponding to the first function and the function name text block corresponding to the second function, the similarity of the function name text between the first function and the second function can be accurately determined. This helps to accurately determine whether the first function and the second function are parallel functions based on the similarity of the function name text between the first function and the second function, thereby improving the accuracy of parallel function determination.
[0090] As an optional embodiment, Figure 5 As shown, S404 may specifically include the following S501-S504:
[0091] S501, obtaining a first internal text block corresponding to an internal calling function of a first function and a second internal text block corresponding to an internal calling function of a second function;
[0092] S502, obtaining a union of the first internal text block and the function name text block corresponding to the first function to obtain a first text block set, and obtaining a union of the second internal text block and the function name text block corresponding to the second function to obtain a second text block set;
[0093] S503, determining a second text block intersection and a second text block union based on the first text block set and the second text block set;
[0094] S504: Update the first similarity according to the second text block intersection and the second text block union to obtain a second similarity between the first function and the second function.
[0095] In this embodiment, assuming that the first function is A1, which calls functions A2 and A3 internally, the first text block set includes function name text blocks corresponding to the three functions A1, A2 and A3 respectively; assuming that the second function is B1, which calls functions B2 and B3 internally, the second text block set includes function name text blocks corresponding to the three functions B1, B2 and B3 respectively.
[0096] Specifically, the text block set can be determined by the following formula 2:
[0097] Formula 2
[0098] In the formula, represents the set of text blocks corresponding to the vth function, Represents the internal text block corresponding to the internal call function of the vth function. A text block representing the function name of the vth function. Represents a union operation.
[0099] Among them, the internal text block corresponding to the internal call function of the vth function It can be determined by the following formula 3:
[0100] Formula 3
[0101] In the formula, Represents the internal text block corresponding to the i-th called function of the v-th function. Represents the internal text block corresponding to the i+1th called function of the vth function. Indicates the accumulation of functions from the ith call to the ith The internal text block corresponding to the called function, Represents the total number of functions called by the vth function, Represents a union operation.
[0102] Among them, when the number of internal text blocks corresponding to the function called by the vth function is more, the number of text blocks included in the text block set is more.
[0103] As an example, after obtaining the first text block set and the second text block set, the server uses the Jaccard similarity coefficient as an indicator to update the first similarity. Specifically, the Jaccard similarity is defined as the size of the intersection of the first text block set and the second text block set divided by the size of the union of the first text block set and the second text block set.
[0104] For example, assuming that the size of the intersection of the first text block set and the second text block set is 1 text block, and the size of the union of the first text block set and the second text block set is 5 text blocks, then the Jaccard similarity corresponding to the first text block set and the second text block set is 0.2. Assuming that the first similarity is 0.5, the server can then use the weighted average method to obtain the second similarity of (0.5+0.2) / 2=0.35.
[0105] Through this embodiment, after calculating the first similarity between the first function and the second function according to the function name text block corresponding to the first function and the function name text block corresponding to the second function. Then consider the internal implementation of the first function and the second function, and update the first similarity by analyzing the functions they call respectively, so as to obtain the second similarity between the first function and the second function. In this way, through the more accurate second similarity between the first function and the second function, it is possible to accurately determine whether the first function and the second function are parallel functions, thereby improving the accuracy of parallel function determination.
[0106] As an optional embodiment, S504 may specifically include:
[0107] Divide the second text block intersection by the second text block union to obtain a first calculated value;
[0108] The first similarity is multiplied by the accumulated value of the first calculated value and the preset correction coefficient to obtain a second similarity between the first function and the second function.
[0109] In this embodiment, the second similarity can be specifically determined by the following formula 4:
[0110] Formula 4
[0111] In this embodiment, represents the second similarity between the u-th function and the v-th function. represents the set of text blocks corresponding to the vth function, represents the set of text blocks corresponding to the u-th function, represents the union operation, Represents the intersection operation. represents the intersection of the text block set corresponding to the vth function and the text block set corresponding to the uth function, Represents the union of the set of text blocks corresponding to the vth function and the set of text blocks corresponding to the uth function. represents the first similarity between the u-th function and the v-th function.
[0112] in, Indicates the number of common text words between the text block set corresponding to the vth function and the text block set corresponding to the uth function, as a percentage of the total number of text words in the two text block sets. The larger the proportion, the greater the second similarity between the uth function and the vth function. The first similarity between the uth function and the vth function The larger it is, the greater the second similarity between the corresponding u-th function and the v-th function will be.
[0113] The second similarity between the uth function and the vth function The larger it is, the greater the possibility that the u-th function and the v-th function are parallel functions.
[0114] Through this embodiment, the internal implementation of the first function and the second function is comprehensively considered, and the first similarity is updated by analyzing the functions they call respectively, so as to obtain the second similarity between the first function and the second function. This helps to accurately determine whether the first function and the second function are parallel functions based on the second similarity between the first function and the second function, thereby improving the accuracy of parallel function determination.
[0115] As an optional embodiment, S103 may specifically include:
[0116] Based on the program call graph and the parallel functions, determine a first execution sequence corresponding to a first matching function in the parallel functions and a second execution sequence corresponding to a second matching function in the parallel functions;
[0117] Based on the first execution sequence and the second execution sequence, determining a sequence similarity between the first execution sequence and the second execution sequence;
[0118] When the sequence similarity does not meet the preset similarity condition, the first execution sequence and the second execution sequence are extended until the sequence similarity between the extended first execution sequence and the second execution sequence meets the preset similarity condition, thereby obtaining the redundant code segment of the target mobile application.
[0119] In this embodiment, the first matching function and the second matching function form a set of parallel functions.
[0120] The first execution sequence is used to represent the function call structure corresponding to the first matching function, and the second execution sequence is used to represent the function call structure corresponding to the second matching function.
[0121] As an example, the server first determines the parallel functions in the target mobile application. Then, after determining the parallel functions, the server obtains the upstream function and the downstream function corresponding to the first matching function in the parallel functions, and constructs the first execution sequence corresponding to the first matching function. Figure 6 As shown, a schematic diagram of a first execution sequence of a first matching function is provided, wherein "calculate_total_sum" is the first matching function in the parallel function.
[0122] Assume that the second matching function corresponding to "calculate_total_sum" is "calculate function + getinfo function". At this time, there are no restrictions on the upstream and downstream functions of the second matching function, and there are multiple possible execution sequences corresponding to it. Then, the multiple possible execution sequences corresponding to it are matched in the program call graph of the target mobile application respectively to determine whether the possible execution sequence exists in the program call graph of the target mobile application. If the possible execution sequence exists, the possible execution sequence is determined as the second execution sequence. For example, Figure 7 As shown, a second execution sequence schematic diagram of a second matching function is provided.
[0123] Then, a discrete wavelet transform (DWT) algorithm is used to determine the sequence similarity between the first execution sequence and each second execution sequence. Specifically, the sequence similarity between the first execution sequence and each second execution sequence is equal to the maximum value of the discrete wavelet transform results obtained by the discrete wavelet transform algorithm.
[0124] When the sequence similarity is greater than 0.6, it indicates that the first execution sequence and the second execution sequence are particularly similar, and the first execution sequence and the second execution sequence can be expanded. That is, the upstream and downstream functions of the first execution sequence and the upstream and downstream functions of the second execution sequence are continuously obtained, and then the sequence similarity between the expanded first execution sequence and the second execution sequence is recalculated.
[0125] When the sequence similarity is less than 0.6, it indicates that the first execution sequence and the second execution sequence are less similar. At this time, the expansion is stopped, and the first execution sequence and the second execution sequence with a sequence similarity greater than 0.6 and closest to 0.6 are determined as redundant code segments of the target mobile application.
[0126] Through this embodiment, redundant code segments of the target mobile application are matched according to the program call graph and the parallel functions, which helps to calculate the code redundancy of the target mobile application according to the redundant code segments, and then accurately evaluate the redundant code situation of the mobile application, which can improve the accuracy of the performance evaluation of the mobile application.
[0127] As an optional embodiment, S104 may specifically include:
[0128] Obtaining a second calculated value according to the number of first functions in the redundant code segment and the total number of functions in the program call graph;
[0129] Obtaining a third calculated value according to the second function quantity of the parallel function and the total number of functions in the program call graph;
[0130] The second calculated value is multiplied by the third calculated value to obtain the code redundancy of the target mobile application.
[0131] In this embodiment, the first function number is used to represent the number of functions included in the redundant code segment, and the second function number is used to represent the number of parallel functions.
[0132] As an example, the code redundancy of the target mobile application can be specifically determined by the following formula 5:
[0133] Formula 5
[0134] In the formula, represents the code redundancy of the target mobile application, n1 represents the number of first functions in the redundant code segment, n2 represents the number of second functions of the parallel function, and n represents the total number of functions in the program call graph.
[0135] in, Indicates the ratio of the number of functions with redundant code segments to the total number of functions in the target mobile application. The larger it is, the greater the code redundancy of the target mobile application; Indicates the proportion of parallel functions to the total number of functions of the target mobile application. The larger the value, the greater the code redundancy of the target mobile application.
[0136] Code redundancy of the target mobile application The larger the value is, the more duplicate functions and similar code segments there are in the current code of the target mobile application, and the lower the application performance is.
[0137] Through this embodiment, the code redundancy of the target mobile application is accurately determined according to the number of first functions in the redundant code segment, the number of second functions of the parallel function, and the total number of functions in the program call graph. Therefore, the redundant code situation of the mobile application can be accurately evaluated, and the accuracy of the performance evaluation of the mobile application can be improved.
[0138] A performance evaluation method based on mobile applications. Accordingly, the present invention also provides a specific embodiment of a performance evaluation system for mobile applications.
[0139] Figure 8 A structural diagram of a performance evaluation system for a mobile application is provided. The performance evaluation system 800 for a mobile application may include a call graph acquisition module 810 , a function determination module 820 , a code segment matching module 830 , a redundancy determination module 840 and a performance evaluation module 850 .
[0140] A call graph acquisition module 810 is used to acquire a program call graph of a target mobile application, where the program call graph is used to represent the call relationship between functions of the target mobile application;
[0141] A function determination module 820 is used to determine each parallel function in the target mobile application based on the program call graph, where the parallel function is used to represent functions that implement the same function;
[0142] A code segment matching module 830 is used to match and obtain redundant code segments of a target mobile application according to a program call graph and parallel functions;
[0143] A redundancy determination module 840, configured to determine code redundancy of a target mobile application based on redundant code segments;
[0144] The performance evaluation module 850 is used to evaluate the application performance of the target mobile application according to the code redundancy.
[0145] In the performance evaluation system for mobile applications provided by this embodiment, the program call graph of the target mobile application is first obtained, and then the parallel functions that implement the same function in the target mobile application are determined based on the program call graph. Then, based on the program call graph and the parallel functions, the redundant code segments of the target mobile application are determined. Thus, based on the redundant code segments, the code redundancy of the target mobile application is evaluated, and the performance of the mobile application is evaluated based on the redundant code situation of the mobile application. In this way, the embodiment of the present invention can accurately identify the redundant code situation of the mobile application through the program call graph of the target mobile application and the parallel functions in the target mobile application, thereby accurately evaluating the redundant code situation of the mobile application, and can improve the accuracy of the performance evaluation of the mobile application.
[0146] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0147] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in a different order from the embodiments, or several steps can be performed simultaneously.
[0148] The above is only a specific implementation of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system, module and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It should be understood that the protection scope of the present invention is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be covered within the protection scope of the present invention.
Claims
1. A performance evaluation method for a mobile application, characterized in that: The method comprises: Acquire a program call graph of a target mobile application, wherein the program call graph is used to represent a call relationship between functions of the target mobile application; Based on the program call graph, determining each parallel function in the target mobile application, wherein the parallel function is used to represent functions that implement the same function; According to the program call graph and the parallel function, matching and obtaining the redundant code segments of the target mobile application; Determining code redundancy of the target mobile application based on the redundant code segments; evaluating the application performance of the target mobile application according to the code redundancy; The determining, based on the program call graph, each parallel function in the target mobile application includes: Obtaining function names of a first function and a second function in the program call graph, where the first function and the second function are any two functions selected from the program call graph; Splitting the function names of the first function and the second function respectively to obtain function name text blocks corresponding to the first function and the second function respectively; Determine a first similarity between the first function and the second function based on the function name text block corresponding to the first function and the function name text block corresponding to the second function; updating the first similarity according to an internal calling function of the first function and an internal calling function of the second function to obtain a second similarity between the first function and the second function; When the second similarity is greater than a preset similarity threshold, it is determined that the first function and the second function belong to the parallel functions.
2. The performance evaluation method of mobile applications according to claim 1, characterized in that: The step of obtaining a program call graph of a target mobile application includes: Obtaining a subroutine call graph corresponding to each test case of the target mobile application, wherein the subroutine call graph is used to represent a call relationship between functions corresponding to the test case; Matching each of the subroutine call graphs respectively to obtain overlapping functions in the subroutine call graphs, wherein the overlapping functions are used to represent functions that appear in multiple subroutine call graphs; According to the overlapping functions, each of the subroutine call graphs is spliced to obtain a program call graph of the target mobile application.
3. The performance evaluation method of mobile application according to claim 2, characterized in that: The obtaining of subroutine call graphs corresponding to the test cases of the target mobile application includes: Obtaining each of the test cases corresponding to the target mobile application; Execute each of the test cases respectively and capture the function calling sequence in each of the test cases; According to the function calling sequence in each of the test cases, a subroutine calling graph corresponding to each of the test cases is generated respectively.
4. The performance evaluation method of mobile applications according to claim 1, characterized in that: The determining, based on the function name text block corresponding to the first function and the function name text block corresponding to the second function, a first similarity between the first function and the second function, comprises: Based on the function name text block corresponding to the first function and the function name text block corresponding to the second function, determine a first text block intersection and a first text block union between the first function and the second function; The first text block intersection is divided by the first text block union to obtain a first similarity between the first function and the second function.
5. The performance evaluation method of mobile application according to claim 1, characterized in that: The updating of the first similarity according to the internal calling function of the first function and the internal calling function of the second function to obtain the second similarity between the first function and the second function includes: Obtain a first internal text block corresponding to an internal calling function of the first function and a second internal text block corresponding to an internal calling function of the second function; Taking the union of the first internal text block and the function name text block corresponding to the first function to obtain a first text block set, and taking the union of the second internal text block and the function name text block corresponding to the second function to obtain a second text block set; Determine a second text block intersection and a second text block union based on the first text block set and the second text block set; The first similarity is updated according to the intersection of the second text blocks and the union of the second text blocks to obtain a second similarity between the first function and the second function.
6. The performance evaluation method for mobile applications according to claim 5, characterized in that: The updating of the first similarity according to the intersection of the second text blocks and the union of the second text blocks to obtain the second similarity between the first function and the second function includes: Divide the intersection of the second text blocks by the union of the second text blocks to obtain a first calculated value; The second similarity between the first function and the second function is obtained by multiplying the accumulated value of the first calculated value and the preset correction coefficient by the first similarity.
7. The performance evaluation method of mobile application according to claim 1, characterized in that: The matching and obtaining the redundant code segments of the target mobile application according to the program call graph and the parallel function includes: Based on the program call graph and the parallel functions, determining a first execution sequence corresponding to a first matching function in the parallel functions and a second execution sequence corresponding to a second matching function in the parallel functions; Based on the first execution sequence and the second execution sequence, determining a sequence similarity between the first execution sequence and the second execution sequence; When the sequence similarity does not meet a preset similarity condition, the first execution sequence and the second execution sequence are extended until the sequence similarity between the extended first execution sequence and the second execution sequence meets a preset similarity condition, thereby obtaining the redundant code segment of the target mobile application.
8. The performance evaluation method for mobile applications according to claim 1, characterized in that: The determining, based on the redundant code segments, the code redundancy of the target mobile application includes: Obtaining a second calculated value according to the first number of functions in the redundant code segment and the total number of functions in the program call graph; Obtaining a third calculated value according to the second function quantity of the parallel function and the total number of functions in the program call graph; The second calculated value is multiplied by the third calculated value to obtain the code redundancy of the target mobile application.
9. A performance evaluation system for a mobile application, characterized in that: The system comprises: A call graph acquisition module, used to acquire a program call graph of a target mobile application, wherein the program call graph is used to represent the call relationship between functions of the target mobile application; A function determination module, used to determine each parallel function in the target mobile application based on the program call graph, wherein the parallel function is used to represent functions that implement the same function; The determining, based on the program call graph, each parallel function in the target mobile application comprises: Obtaining function names of a first function and a second function in the program call graph, where the first function and the second function are any two functions selected from the program call graph; The function names of the first function and the second function are split respectively to obtain function name text blocks corresponding to the first function and the second function respectively; Determine a first similarity between the first function and the second function based on the function name text block corresponding to the first function and the function name text block corresponding to the second function; updating the first similarity according to an internal calling function of the first function and an internal calling function of the second function to obtain a second similarity between the first function and the second function; When the second similarity is greater than a preset similarity threshold, determining that the first function and the second function belong to the parallel function; A code segment matching module, used for matching and obtaining redundant code segments of the target mobile application according to the program call graph and the parallel function; A redundancy determination module, configured to determine the code redundancy of the target mobile application based on the redundant code segment; The performance evaluation module is used to evaluate the application performance of the target mobile application according to the code redundancy.
Citation Information
Patent Citations
Repeated code field identification method and device
CN114942769A
Java redundant code evaluation method based on TOPSIS method
CN115408272A