Designated function optimization method, apparatus, device, and storage medium

CN122884865APending Publication Date: 2026-10-09SUZHOU TONGYUAN SOFT CONTROL INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611384928.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-08
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

[0004]本申请的主要目的在于提供一种指定函数优化方法、装置、设备及存储介质,旨在解决如何提高指定函数优化的效率和准确性的技术问题

Benefits of technology

首先,通过接收待优化函数名并解析源码目录、测试目录和性能基准目录,替代人工遍历目录结构,消除因目录层级复杂导致的手动搜索低效和遗漏风险;其次,在源码目录中定位目标函数,得到待优化源码文件路径集合,确保优化范围覆盖全面而不遗漏;进一步地,根据待优化源码文件路径集合分别生成测试文件清单和性能基准用例清单,并通过路径映射规则自动关联目标函数对应的测试用例和性能基准脚本,克服人工梳理关联用例时出现的漏测和用例匹配错误;另外地,创建优化前基线,在基线下运行测试文件和性能基准用例得到基线性能数据集通过建立不可污染的基线,并结合自动化运行清单,提高优化效率;最后,根据基线性能数据集和本地优化技能库生成优化策略并修改源码,替代依赖个人经验的随意修改方式,减少试错次数,从而系统化提升指定函数优化的效率和准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122884865A_ABST
    Figure CN122884865A_ABST
Patent Text Reader

Abstract

The application discloses a specified function optimization method and device, equipment and storage medium, relates to the technical field of engineering software development, and the method comprises the following steps: receiving a function name to be optimized, analyzing a source code directory, a test directory and a performance benchmark directory of a professional toolbox function library; locating a target function corresponding to the function name to be optimized in the source code directory to obtain a set of source code file paths to be optimized; generating a test file list and a performance benchmark case list according to the set of source code file paths to be optimized, the test directory and the performance benchmark directory; creating a baseline before optimization, running the test file list and the performance benchmark case list in the state of the baseline before optimization to obtain a baseline performance data set; generating an optimization strategy according to the baseline performance data set and a local optimization skill library, and modifying the implementation code of the target function in the source code directory according to the optimization strategy to obtain a modified target source code file. The application aims to improve the efficiency and accuracy of specified function optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of engineering software development technology, and in particular to methods, apparatus, devices and storage media for optimizing specified functions. Background Technology

[0002] When optimizing a specific function in a professional toolbox library, developers need to manually locate the complete definition of the target function and the methods corresponding to all parameter types in the source code directory, manually compile test cases and performance measurement scripts associated with the function in the test directory and performance benchmark directory, and manage the code version before optimization or manually back up the original implementation to establish a performance comparison baseline. After completing the code modification, they need to repeatedly perform multiple verification operations such as testing, type stability diagnosis, and performance benchmark measurement, and manually judge the effectiveness of the optimization based on the scattered measurement data. Due to the excessive reliance on manual intervention and the fragmented optimization process, the optimization process of a specified function is not only time-consuming but also prone to problems such as missed tests, inconsistent baselines, and incomplete verification. The correctness and reproducibility of manual operations are difficult to guarantee.

[0003] Therefore, how to improve the efficiency and accuracy of the optimization of a specified function has become a technical problem that this application urgently needs to solve. Summary of the Invention

[0004] The main objective of this application is to provide a method, apparatus, device, and storage medium for optimizing a specified function, aiming to solve the technical problem of how to improve the efficiency and accuracy of optimizing a specified function.

[0005] To achieve the above objectives, this application proposes a specified function optimization method, the method comprising: Receive the name of the function to be optimized and parse the source code directory, test directory, and performance benchmark directory of the professional toolbox function library; Locate the target function corresponding to the name of the function to be optimized in the source code directory to obtain the set of source code file paths to be optimized. Based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory, generate a test file list and a performance benchmark test case list, respectively. Create a baseline before optimization, and run the test file list and the performance benchmark test case list under the state of the baseline before optimization to obtain the baseline performance dataset; An optimization strategy is generated based on the baseline performance dataset and a pre-built local optimization skill library. The implementation code of the objective function is then modified in the source code directory according to the optimization strategy to obtain the modified objective source code file.

[0006] Furthermore, to achieve the above objectives, this application also proposes a specified function optimization apparatus, which includes: The function library structure parsing module is used to receive the name of the function to be optimized and parse the source code directory, test directory and performance benchmark directory of the professional toolbox function library; The function location module is used to locate the target function corresponding to the name of the function to be optimized in the source code directory, and obtain the set of source code file paths to be optimized. The mapping module is used to generate a test file list and a performance benchmark test case list based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory, respectively. The baseline management module is used to create a pre-optimization baseline, and run the test file list and the performance benchmark test case list in the state of the pre-optimization baseline to obtain the baseline performance dataset; The optimization execution module is used to generate an optimization strategy based on the baseline performance dataset and a pre-built local optimization skill library, and modify the implementation code of the target function in the source code directory according to the optimization strategy to obtain the modified target source code file.

[0007] In addition, to achieve the above objectives, this application also proposes a specified function optimization device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the specified function optimization method as described above.

[0008] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the specified function optimization method as described above.

[0009] One or more technical solutions proposed in this application have at least the following technical effects: First, by receiving the name of the function to be optimized and parsing the source code directory, test directory, and performance benchmark directory, the system replaces manual directory traversal, eliminating the inefficiency and risk of omissions caused by complex directory hierarchies. Second, it locates the target function in the source code directory, obtaining a set of source code file paths to be optimized, ensuring comprehensive and thorough optimization coverage. Further, it generates a list of test files and a list of performance benchmark test cases based on the set of source code file paths, and automatically associates the test cases and performance benchmark scripts corresponding to the target function through path mapping rules, overcoming the omissions and test case matching errors that occur when manually sorting and associating test cases. Additionally, it creates a baseline before optimization, and runs the test files and performance benchmark test cases under the baseline to obtain a baseline performance dataset. By establishing an uncontaminated baseline and combining it with automated run lists, optimization efficiency is improved. Finally, it generates optimization strategies based on the baseline performance dataset and a local optimization skill library, and modifies the source code, replacing arbitrary modifications based on personal experience, reducing trial and error, and thus systematically improving the efficiency and accuracy of optimizing the specified function. Attached Figure Description

[0010] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0011] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the 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.

[0012] Figure 1 A flowchart is provided for the first embodiment of the function optimization method specified in this application; Figure 2 A flowchart is provided for the second embodiment of the function optimization method specified in this application; Figure 3 A flowchart is provided for the third embodiment of the function optimization method specified in this application; Figure 4 A schematic diagram of the module structure of the function optimization device specified in the embodiments of this application; Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the specified function optimization method in the embodiments of this application.

[0013] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0014] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0015] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0016] The main solution of this application embodiment is as follows: receiving the name of the function to be optimized, parsing the source code directory, test directory, and performance benchmark directory of the professional toolbox function library; locating the target function corresponding to the name of the function to be optimized in the source code directory to obtain a set of source code file paths to be optimized; generating a test file list and a performance benchmark test case list based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory respectively; creating a pre-optimization baseline, running the test file list and the performance benchmark test case list in the state of the pre-optimization baseline to obtain a baseline performance dataset; generating an optimization strategy based on the baseline performance dataset and a pre-built local optimization skill library, modifying the implementation code of the target function in the source code directory according to the optimization strategy to obtain the modified target source code file.

[0017] In this embodiment, for ease of description, the following description will focus on the specified function optimization system as the execution subject.

[0018] This application takes into account that, in the field of scientific computing and engineering simulation, professional toolbox function libraries (such as signal processing, control optimization, mathematical calculation and other toolkits in MWORKS Syslab) are deliverable engineering assets, and the performance and reliability of their function implementations directly affect the efficiency and accuracy of upper-level algorithm development, numerical calculation and engineering verification.

[0019] When optimizing a specific function in a professional toolbox library, developers need to manually locate the complete definition of the target function and the methods corresponding to all parameter types in the source code directory, manually compile test cases and performance measurement scripts associated with the function in the test directory and performance benchmark directory, and manage the code version before optimization or manually back up the original implementation to establish a performance comparison baseline. After completing the code modification, they need to repeatedly perform multiple verification operations such as testing, type stability diagnosis, and performance benchmark measurement, and manually judge the effectiveness of the optimization based on the scattered measurement data. Due to the excessive reliance on manual intervention and the fragmented optimization process, the optimization process of a specified function is not only time-consuming but also prone to problems such as missed tests, inconsistent baselines, and incomplete verification. The correctness and reproducibility of manual operations are difficult to guarantee.

[0020] At the system software layer, MWORKS provides core supporting capabilities such as function libraries, scientific computing environments, system modeling and simulation environments, and model libraries. Syslab, as a scientific computing environment, supports tasks such as programming, mathematics, graphics, code generation, and parallel computing, supporting algorithm development, numerical computation, data analysis, and engineering calculations. The specialized toolbox function libraries are collections of functions within Syslab for specialized fields such as signal processing, control, optimization, and mathematical computation. Their function implementations, test cases, performance benchmarks, and documentation together constitute maintainable, verifiable, and deliverable engineering assets. The specified function optimization method proposed in this application is primarily aimed at specialized toolbox function libraries such as MWORKS Syslab.

[0021] Therefore, this application provides a solution. First, by receiving the name of the function to be optimized and parsing the source code directory, test directory, and performance benchmark directory, it replaces manual traversal of the directory structure, eliminating the inefficiency and risk of omissions caused by complex directory hierarchies in manual searches. Second, it locates the target function in the source code directory, obtaining a set of source code file paths to be optimized, ensuring comprehensive and thorough optimization coverage. Further, it generates a list of test files and a list of performance benchmark test cases based on the set of source code file paths to be optimized, and automatically associates the test cases and performance benchmark scripts corresponding to the target function through path mapping rules, overcoming the omissions and test case matching errors that occur when manually sorting and associating test cases. Additionally, it creates a baseline before optimization, runs test files and performance benchmark test cases under the baseline to obtain a baseline performance dataset. By establishing an uncontaminated baseline and combining it with automated run lists, optimization efficiency is improved. Finally, it generates optimization strategies based on the baseline performance dataset and a local optimization skill library, and modifies the source code, replacing arbitrary modifications based on personal experience, reducing the number of trial and error attempts, thereby systematically improving the efficiency and accuracy of optimizing the specified function.

[0022] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or a specified function optimization system capable of performing the above functions. The following description uses a specified function optimization system as an example to illustrate this embodiment and the subsequent embodiments.

[0023] Based on this, embodiments of this application provide a method for optimizing a specified function, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the function optimization method specified in this application.

[0024] In this embodiment, the specified function optimization method includes steps S10 to S50: Step S10: Receive the name of the function to be optimized, and parse the source code directory, test directory, and performance benchmark directory of the professional toolbox function library; It should be noted that the name of the function to be optimized refers to the name of the target function that needs to be optimized by the user; the professional toolbox function library refers to a collection of functions for professional fields such as signal processing, control, optimization, and mathematical calculation, including complete engineering assets such as source code, test cases, and performance benchmark scripts.

[0025] The source code directory contains the function implementation code; the test directory contains the test scripts used to verify the correctness of the functions; and the performance benchmark directory contains the performance measurement scripts used to record performance metrics such as function execution time and memory usage.

[0026] Specifically, the system's task input module receives the name of the function to be optimized specified by the user, and also receives the optional toolbox root directory, source code files, test files, and performance benchmark files; if the user does not specify the toolbox root directory, the current working directory is used as the default root directory. Further, the system calls the function library structure parsing module to read the project configuration file of the professional toolbox function library, identify and record the root directory path, and scan and determine the path mapping relationships of the source code directory, test directory, performance benchmark directory, temporary directory, and report directory under the root directory.

[0027] In addition, when the professional toolbox function library contains multiple professional directions or sub-modules, the function library structure parsing module also records the module path and relative path of each target function, providing a path basis for the mapping of subsequent test cases and performance test cases.

[0028] Step S20: Locate the target function corresponding to the name of the function to be optimized in the source code directory to obtain the set of source code file paths to be optimized; It should be noted that the set of source code file paths to be optimized refers to the collection recording the source code file paths of each method of the target function, for use in subsequent test mapping and performance mapping. The phrase "methods corresponding to multiple parameter types" refers to the same function name providing multiple specific implementations for different input parameter types, a common mechanism for achieving polymorphism in scientific computing environments.

[0029] Specifically, the system's function location module takes the unique identifier of the target function as input, searches for the target function in the source code directory that matches the name of the function to be optimized, and identifies the function definition and function methods corresponding to the target function.

[0030] Furthermore, the function location module checks whether the target function is exported from the toolbox entry file of the professional toolbox function library. If the target function is not exported from the toolbox entry file, it is marked as an internal function and recorded in a subsequent report. When multiple function methods exist, the function location module filters the set of methods related to the target load from the multiple function methods based on the subsequent test file list, performance benchmark test case list, and call path information, avoiding modification of implementations unrelated to the target load. Finally, the source code file paths corresponding to the method set are recorded as a set of source code file paths to be optimized.

[0031] Step S30: Generate a test file list and a performance benchmark test case list based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory, respectively. It should be noted that the test file list is a list of test files associated with the target function, used to verify the correctness of the function before and after optimization; the performance benchmark test case list is a list of performance measurement scripts associated with the target function, used to collect performance indicators such as runtime and memory allocation before and after optimization.

[0032] Each test case script in the “performance benchmark test case list” may contain dependency metadata (indicating toolkits or base libraries that need to be preloaded) and a test preparation end marker (function calls following this marker are identified as the target load entry point, i.e., the actual object of performance measurement).

[0033] Specifically, the system calls the test mapping module to obtain the relative paths of each source file in the set of source file paths to be optimized. Based on the test directory, the source directory prefix in the relative path is replaced with the test directory prefix to generate candidate test file paths. If the test file corresponding to the candidate test file path exists, it is added to the test file list. If it does not exist, the system further searches for test files that reference the target function in the test directory and adds the searched test files to the test file list. If the search still fails to find a match, the system checks whether the function library-level test entry file exists.

[0034] Furthermore, the system calls the performance test case mapping module to search for the performance test folder corresponding to the source code level of the function name or source code file path set to be optimized in the performance benchmark directory, and adds all performance test case scripts under the performance test folder to the performance benchmark test case list; then, it parses the dependency metadata of each performance test case script in the performance benchmark test case list, records the toolbox or basic library information to be loaded, and checks whether there is a test preparation end mark in the performance test case script. If there is, the function call after the test preparation end mark is recorded as the target load entry point.

[0035] Step S40: Create a baseline before optimization, and run the test file list and the performance benchmark test case list in the state of the baseline before optimization to obtain the baseline performance dataset; It should be noted that the baseline before optimization refers to a snapshot of the current source code state before any code modifications are implemented. This snapshot is used to restore the original state if the optimization decision fails, and also serves as a benchmark for performance comparison.

[0036] The baseline performance dataset refers to the summary data of all verification results and performance metrics collected by running the test file list and performance benchmark test case list in the baseline state before optimization. Specifically, it includes test pass / fail results, type stability diagnostic information, and median runtime, first runtime, memory usage, and allocation count for each performance test case.

[0037] The "type stability diagnostic information" is obtained by executing a type inference diagnostic command and is used to identify dynamic types, unstable joint types, and the location of inference accuracy loss.

[0038] Specifically, the system calls the baseline management module to create a baseline before optimization: when the professional toolbox function library is located in the version management repository, the baseline is built using the current version, the user-specified version, or the differences in the working area before optimization, and the existing uncommitted modifications in the working area are identified to avoid subsequent overwriting; when the version management status cannot reliably express the baseline, a temporary snapshot or temporary patch file is created in the temporary directory as the baseline before optimization; the baseline management module prohibits the addition of original copies or backup copy directories in the source code directory.

[0039] After the baseline is created before optimization, the system calls the verification decision module to run the test cases in the test file list to perform correctness verification under the baseline state. It then executes type inference diagnostic commands to check the type stability of each method in the objective function, recording the location and diagnostic information of dynamic types, unstable joint types, and inference accuracy loss. Next, it runs each performance test case in the performance benchmark test case list, performing performance measurements according to the target load entry point, and recording the median runtime, first runtime, memory usage, and allocation count using performance measurement commands. When the performance benchmark test case list contains multiple performance test cases, all performance test cases are executed sequentially in a single process, and measurement data is recorded separately for each. Finally, the correctness verification results, type stability diagnostic information, and performance measurement data of each performance test case are summarized to form the baseline performance dataset.

[0040] Step S50: Generate an optimization strategy based on the baseline performance dataset and the pre-built local optimization skill library; modify the implementation code of the objective function in the source code directory according to the optimization strategy to obtain the modified target source code file.

[0041] It should be noted that the local optimization skill library is a pre-built set of optimization rules, including performance code pattern rules, best practice rules for memory allocation, type stability diagnostic rules, runtime hotspot sampling rules, and performance comparison rules before and after. The optimization strategy refers to the targeted code modification scheme selected and generated from the local optimization skill library based on the diagnostic information and hotspot distribution in the baseline performance dataset.

[0042] Specifically, the system calls the skill scheduling module to parse the baseline performance dataset and identify optimization opportunities: locate code locations with dynamic types, unstable joint types, and inference precision loss as candidate points for type stability optimization; locate memory allocation hotspots by combining memory usage and allocation count data, and identify problems such as slice copying, allocation within loops, and repeated container expansion; and identify code segments with concentrated runtime as runtime hotspot locations.

[0043] Furthermore, based on the identified optimization opportunities, the system invokes the local optimization skill library to generate optimization strategies. For example, for type stability issues, it invokes type stability diagnostic rules to generate strategies that concretize container and loop state types and add function barriers to isolate dynamic logic. The system's optimization execution module determines the location and method of code modification based on the optimization strategy, directly modifies the implementation code of the target function in the source code directory, and records the specific content of the optimization strategy applied, the scope of the modified code lines, and a description of the modification method. Finally, the modified code is saved as the modified target source code file.

[0044] This embodiment provides a method for optimizing a specified function. First, it receives the name of the function to be optimized and parses the source code directory, test directory, and performance benchmark directory, replacing manual traversal of the directory structure and eliminating the inefficiency and risk of omissions caused by complex directory hierarchies. Second, it locates the target function in the source code directory, obtaining a set of source code file paths to be optimized, ensuring comprehensive and thorough optimization. Further, it generates a list of test files and a list of performance benchmark test cases based on the set of source code file paths to be optimized, and automatically associates the test cases and performance benchmark scripts corresponding to the target function through path mapping rules, overcoming the omissions and test case matching errors that occur when manually sorting and associating test cases. Additionally, it creates a baseline before optimization, runs the test files and performance benchmark test cases under the baseline to obtain a baseline performance dataset. By establishing an uncontaminated baseline and combining it with an automated run list, optimization efficiency is improved. Finally, it generates an optimization strategy based on the baseline performance dataset and a local optimization skill library, and modifies the source code, replacing arbitrary modifications based on personal experience, reducing trial and error, and thus systematically improving the efficiency and accuracy of specified function optimization.

[0045] Based on the first embodiment of this application, a second embodiment of this application is proposed. In the second embodiment of this application, the same or similar contents as those in the first embodiment can be referred to the above description, and will not be repeated hereafter.

[0046] Based on this, please refer to Figure 2 , Figure 2 The flowchart of the second embodiment provided in this application is as follows: Figure 2 As shown, steps S50 are followed by steps S60 to S90: Step S60: Rerun the test file list and the performance benchmark test case list according to the modified target source code file to obtain the optimized performance dataset; It should be noted that the optimized performance dataset refers to the summary data of all verification results and performance metrics collected by rerunning the test file list and performance benchmark test case list under the modified target source code file state. Its data dimensions are consistent with the baseline performance dataset. Specifically, it includes the optimized test pass / fail results, optimized type stability diagnostic information, and the median runtime, first runtime, memory usage and allocation count of each performance test case after optimization. It is used to compare with the baseline performance dataset item by item to determine the optimization effect.

[0047] Specifically, under the modified target source code file's code state, the test cases in the test file list are rerun to perform correctness verification, recording the pass or fail results; the type inference diagnostic command is rerun to perform type stability checks on each method of the modified target function, recording the location and diagnostic information of dynamic types, unstable joint types, and inference precision loss; each performance test case in the performance benchmark test case list is rerun, performing performance measurements according to the target load entry point, recording the optimized median runtime, first runtime, memory usage, and allocation count using the performance measurement command; when the performance benchmark test case list contains multiple performance test cases, all performance test cases are executed sequentially in a single process, and the optimized measurement data is recorded separately. Finally, the optimized correctness verification results, type stability diagnostic information, and performance measurement data of each performance test case are summarized into an optimized performance dataset.

[0048] Step S70: Perform a retention decision or a rollback decision based on the optimized performance dataset and the baseline performance dataset; It should be noted that the retention decision refers to deciding to retain the modified target source code file as the final code state when the optimized performance meets the preset conditions; the rollback decision refers to deciding to abandon the modifications and restore the code state to the baseline before optimization when the optimized performance does not meet the preset conditions or the test fails.

[0049] The system calls the verification decision module to compare the optimized performance dataset with the baseline performance dataset item by item, and performs decision-making based on preset retention and rollback rules: If the mapping test fails, the modification is rejected directly and a rollback decision is triggered; for a single performance test case, a retention decision is triggered when the median runtime is faster than the baseline, or when the median runtime rollback is less than a preset percentage and the memory allocation reduction exceeds a preset percentage; for multiple performance test cases, a retention decision is triggered when the proportion of faster test cases reaches a preset threshold and the median runtime rollback of all non-faster test cases is lower than a preset threshold; if the optimized median runtime is significantly slower than the baseline, it is remeasured, and if the conditions are still not met, a rollback decision is triggered and it is marked as requiring manual review; when the optimization has no substantial effect, a runtime hotspot analysis is triggered to guide the next round of optimization.

[0050] Step S80: Determine the final source code state of the objective function through the retention decision or the rollback decision; It should be noted that the final source code state refers to the final code form of the objective function in the source code directory after the retention decision or the rollback decision is determined.

[0051] Specifically, when the verification decision module outputs the retention decision, the system's baseline management module retains the current state of the modified target source code file in the source code directory, confirms it as the final source code state, and clears the temporary snapshots or temporary patch files created in the temporary directory during this task; when the verification decision module outputs the rollback decision, the baseline management module restores the source code state of the baseline before optimization to the source code directory, overwrites the modified target source code file, so that the objective function returns to the code form before optimization, and records the rollback reason and negative optimization evidence.

[0052] Step S90: Generate an optimization report and a performance comparison file based on the final source code status.

[0053] It should be noted that the optimization report refers to a structured document written in Chinese that records all information of the entire optimization process. Specifically, it includes the target function name, source code location, export status, optimization target, scope of modification, test commands, type stability findings, performance test cases, optimization methods, performance comparison, conclusions on retention or rollback, risks, and trade-offs. The performance comparison file is a spreadsheet file that contains at least two worksheets: time optimization and memory comparison. All performance data is recorded using scientific notation and is used for engineering review, archiving, and subsequent performance regression tracking.

[0054] Specifically, the system generates an optimization report in the report directory corresponding to the objective function. The optimization report includes at least the objective function name, source code location, export status, optimization target, modification scope, test commands, type stability findings, performance test cases, optimization methods, performance comparison, retention or rollback conclusions, risks, and trade-offs. Furthermore, the system generates a performance comparison file, which is a spreadsheet file containing at least two worksheets: time optimization and memory comparison. All performance data is recorded using scientific notation.

[0055] In this embodiment, by optimizing and automatically retesting, type diagnosis and performance comparison, combined with preset rules to quantitatively decide whether to retain or roll back, the optimization conclusions are ensured to be objective and traceable; finally, a Chinese report and an Excel comparison file are generated, which significantly reduces the cost of manual review.

[0056] Based on any of the above embodiments of this application, a third embodiment of this application is proposed. In the third embodiment of this application, the same or similar content as any of the above embodiments can be referred to the above description, and will not be repeated hereafter.

[0057] Based on this, please refer to Figure 3 , Figure 3 The flowchart of the third embodiment provided in this application is as follows: Figure 3 As shown, in this embodiment, step S10 may include steps S11 to S12: Step S11: Read the project configuration file of the professional toolbox function library and identify the root directory path of the professional toolbox function library according to the project configuration file; The system reads the root directory of the professional toolbox function library, locates and reads the project configuration file of the professional toolbox function library within that directory. This project configuration file is a file in the root directory of the professional toolbox function library that describes the library's metadata, including key configuration information such as the toolbox name, entry file path, exported function list, source code hierarchy, test hierarchy, and performance benchmark hierarchy.

[0058] Furthermore, the system parses and identifies the root directory path of the professional toolbox function library from the project configuration file, and at the same time confirms the toolbox name, entry file path, exported function list, source code hierarchy, test hierarchy, and performance benchmark hierarchy, providing path basis for subsequent parsing of each core subdirectory.

[0059] Step S12: Read the source code directory, the test directory, and the performance benchmark directory according to the root directory path.

[0060] The system calls the function library structure parsing module, which, based on the directory naming conventions recorded in the project configuration file (e.g., src represents the source code directory, test represents the test directory, and benchmark represents the performance benchmark directory), identifies and records the complete paths of the source code directory, test directory, and performance benchmark directory under the root directory path.

[0061] For function libraries containing multiple professional directions or multiple sub-modules, the function library structure parsing module also records the module path and relative path of each function, providing a path basis for subsequent test case and performance test case mapping.

[0062] In this embodiment, by automatically reading the project configuration and parsing the root directory, source code, test, and benchmark directories, the standardized identification and path mapping of the function library structure are achieved, providing an accurate foundation for subsequent location and use case association, avoiding path errors caused by manual specification, and improving the degree of process automation.

[0063] Based on any of the above embodiments of this application, a fourth embodiment of this application is proposed. In the fourth embodiment of this application, the same or similar content as any of the above embodiments can be referred to the above description, and will not be repeated hereafter.

[0064] In this embodiment, step S20 may include steps S21 to S25: Step S21: Search the source code directory for a target function that matches the name of the function to be optimized; Specifically, the system takes the name of the function to be optimized as input and traverses the source code directory to search for target functions that match the name of the function to be optimized. During the search, the system uses a function location module to simultaneously identify both the complete function definition and the abbreviated function definition of the target function, ensuring that no implementation form is missed.

[0065] Step S22: Identify the function definition and function method corresponding to the target function, and check whether the target function is exported from the toolbox entry file of the professional toolbox function library; Furthermore, the system takes all definition locations of the target function as input, parses the code at each definition location, and identifies the function definition and function methods (i.e., different implementations corresponding to multi-parameter types) corresponding to the target function. Additionally, the system uses a function location module to check whether the target function is listed in the export list of the toolbox entry file of the professional toolbox function library, to determine whether the function is a publicly available exported function or a private function for internal use only.

[0066] Step S23: If the target function is not exported from the toolbox entry file of the professional toolbox function library, then the target function is marked as an internal function; If the target function is not exported from the toolbox entry file of the professional toolbox function library, the function location module will mark the target function as an internal function and record it in the subsequent optimization report.

[0067] Understandably, marking the objective function as an internal function plays a crucial role in determining the subsequent test scope: for objective functions marked as internal functions, the system prioritizes running the narrowest set of reliable tests; for derived functions, it runs a wider range of function library-level tests.

[0068] Step S24: If multiple function methods exist, select a set of methods related to the target load from the multiple function methods; When the target function has multiple methods (i.e., the same function name has multiple implementations with different parameter types), the system selects a set of methods related to the target load from these methods based on the user-specified target load characteristics (including input parameter types, calling scenario constraints, etc.) or by analyzing the export configuration of the function library and the usage instructions in the source code comments. If the user does not explicitly specify the target load characteristics, all methods are considered relevant by default, and further confirmation and adjustment will be made based on the baseline performance dataset during the subsequent optimization strategy generation stage.

[0069] The specific filtering logic is as follows: when the user provides a combination of parameter types, only methods whose signatures match that combination are retained; when no combination is provided, public methods exported from the toolbox entry file are retained first, and internal methods are marked for subsequent decision-making, so as to avoid overly narrowing the optimization scope and missing potential performance bottlenecks.

[0070] Step S25: Record the source code file paths corresponding to the method set as the source code file path set to be optimized.

[0071] The system obtains the absolute path or path relative to the root directory of the source code file containing each method in the method set, and summarizes these paths into a set of source code file paths to be optimized. Each path in this set corresponds to a source code file that actually contains the implementation of a method of the target function. Subsequent steps will map the corresponding test files and performance benchmark test cases according to this set of paths.

[0072] Further, step S30, which generates a test file list and a performance benchmark test case list based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory, may include steps S31 to S34: Step S31: Obtain the relative path of each source file in the set of source file paths to be optimized, and replace the source directory prefix in the relative path with the test directory prefix based on the test directory to generate candidate test file paths; Specifically, the system calls the test mapping module. The test mapping module first calculates the relative path of each source file in the set of source file paths to be optimized relative to the root directory. Then it obtains the directory structure in the relative path, replaces the top-level source directory prefix with the test directory prefix, and keeps all subdirectory levels and file names in the relative path unchanged except for the prefix, thereby generating candidate test file paths.

[0073] Step S32: Generate a list of test files based on the candidate test file paths; Specifically, the test mapping module checks one by one whether the test file corresponding to each candidate test file path actually exists in the file system; if it exists, the candidate path is added to the test file list. If the file corresponding to the candidate test file path does not exist, the test mapping module starts a search fallback mechanism, searches for test files referencing the target function in the test directory, and adds the found test files to the test file list; if the search still fails to find a match, it checks whether the function library-level test entry file exists.

[0074] Step S33: Locate the performance test folder in the performance benchmark directory that corresponds to the name of the function to be optimized or the source code level in the set of source code file paths to be optimized. Specifically, the performance test case mapping module searches within the performance benchmark directory. The search strategy is as follows: first, it searches for performance test folders in the performance benchmark directory that exactly match the name of the function to be optimized; if not found, it searches for performance test folders in the performance benchmark directory that correspond to the source code hierarchy structure of the relative paths of each source code file in the set of source code file paths to be optimized; once the performance test folder is located, the performance test case mapping module also parses the dependency metadata of each script within it.

[0075] Step S34: Run the performance test folder to generate a list of performance benchmark test cases.

[0076] Specifically, the performance test case mapping module iterates through all script files in the performance test folder, adding each script as a performance baseline test case to the performance baseline test case list. For each performance test case in the list, the performance test case mapping module parses the dependency metadata in the script, records the required toolboxes or base libraries, and checks whether there is a test preparation end marker in the performance test case script. If so, the function call after the test preparation end marker is marked as the target load entry point for that test case.

[0077] In this embodiment, by automatically locating the multi-method definition and export status, path mapping and fallback search, test and performance test cases are accurately associated, and dependencies and load entry points are parsed, ensuring the completeness of the optimization scope and the absence of verification test cases, which greatly improves the accuracy and automation level of subsequent baseline construction and optimization decisions.

[0078] Based on any of the above embodiments of this application, a fifth embodiment of this application is proposed. In the fifth embodiment of this application, the same or similar content as any of the above embodiments can be referred to the above description, and will not be repeated hereafter.

[0079] In this embodiment, step S40, which involves creating a pre-optimization baseline and running the test file list and the performance benchmark test case list under the pre-optimization baseline state to obtain the baseline performance dataset, may include steps S41 to S45: Step S41: When the professional toolbox function library is located in the version control repository, create a baseline before optimization; It should be noted that a version control repository is a version control system repository (such as a Git repository) used to track the history of source code changes. It can provide information such as the current version identifier and working directory differences for building a baseline.

[0080] Specifically, the system first checks whether the professional toolbox function library is located in the version management repository through the baseline management module. When it is located in the version management repository, it prioritizes using the current version, the user-specified version, or the differences in the workspace before optimization to build the baseline before optimization, and records the current version identifier or difference content.

[0081] When uncommitted changes already exist in the working directory, identify and record the uncommitted changes to avoid overwriting or rolling back them later. When the version control status cannot reliably represent the baseline before optimization, create a temporary snapshot or temporary patch file in the temporary directory that is only used for the current task as the baseline before optimization, and prohibit adding original copy files or backup copy directories to the source code directory.

[0082] Step S42: Run the test cases in the test file list to perform correctness verification in the state of the pre-optimization baseline. It should be noted that correctness verification refers to the process of running the test cases and determining whether they all pass. It is a necessary step before and after optimization. If the test fails after optimization, a rollback decision will be triggered directly.

[0083] Specifically, the system invokes the verification decision module, which runs all test cases in the test file list under the pre-optimization baseline state to perform correctness verification. During execution, the execution result (pass or failure) of each test case is recorded, and output logs are collected. If the target function is marked as an internal function, the narrowest set of reliable tests directly corresponding to the set of source code file paths to be optimized is run first; if the target function is an exported function, a shared function, or a high-risk function, a broader range of library-level tests are run. The system summarizes the execution results of the test cases (test pass / fail records) as part of the baseline performance dataset.

[0084] Step S43: Execute the type inference diagnostic command; It should be noted that the type inference diagnostic command is a diagnostic tool used in scientific computing environments to analyze the stability of function types. This command can reveal whether the specific types of each variable inside the function can be inferred at compile time, thereby locating dynamic types, unstable union types, and the location of inference precision loss, which is a key basis for judging type stability.

[0085] Specifically, the system, through the verification decision module, executes type inference diagnostic commands on each method of the objective function in the pre-optimization baseline state, performing type stability checks on each method. After execution, the system collects diagnostic output information, analyzes the marked unstable type variables, the locations of dynamic types, and the lines of code where inference accuracy is lost, and records this diagnostic information in a structured manner as an important basis for subsequently identifying candidate points for type stability optimization. The system summarizes the type stability diagnostic information corresponding to each method of the objective function, as part of the baseline performance dataset.

[0086] Step S44: Run the performance test cases in the performance benchmark test case list to perform performance measurements; Specifically, performance measurements are performed by running each performance test case in the performance baseline test case list under the pre-optimized baseline state. First, the required toolkits or base libraries are loaded according to dependency metadata. Then, performance measurements are performed according to the target load entry point. The median runtime, first runtime, memory usage, and allocation count for each test case are recorded using performance measurement commands. When the performance baseline test case list contains multiple performance test cases, all test cases are executed sequentially in a single process, and measurement data is recorded separately for each. The system summarizes the median runtime, first runtime, memory usage, and allocation count for each performance test case as part of the baseline performance dataset.

[0087] Step S45: Determine the baseline performance dataset by performing correctness verification, executing type inference diagnostic commands, and executing the results of performance measurements.

[0088] The system summarizes and standardizes the test case execution results, type stability diagnostic information, and performance measurement data of each performance test case according to a unified data structure. It associates and records the test execution results (pass / fail and failure details), type stability diagnostic information (location and description of unstable types), and the median runtime, first runtime, memory usage, and allocation count of each performance test case to form a structured baseline performance dataset.

[0089] In this embodiment, a rollbackable baseline is constructed using multiple strategies. Testing, type diagnostics, and performance measurements are automatically performed in the baseline state, forming a structured benchmark dataset. This avoids source code directory contamination, ensures the objectivity and reliability of the comparison data before and after optimization, and provides a quantitative basis for subsequent strategy generation and rollback decisions.

[0090] Based on any of the above embodiments of this application, a sixth embodiment of this application is proposed. In the sixth embodiment of this application, the same or similar content as any of the above embodiments can be referred to the above description, and will not be repeated hereafter.

[0091] In this embodiment, step S50, which generates an optimization strategy based on the baseline performance dataset and a pre-built local optimization skill library, and modifies the implementation code of the objective function in the source code directory according to the optimization strategy to obtain the modified target source code file, may include steps S51 to S53: Step S51: Analyze the baseline performance dataset to identify optimization opportunities; It should be noted that optimization opportunities refer to the locations of code that can be improved and their corresponding directions of improvement identified from the baseline performance dataset. Specifically, they include three categories: type stability optimization candidate points (dynamic types, unstable union types, and locations of inference precision loss located by type stability diagnostic information), memory allocation problems (redundant copying, deep copying, forced collection, slice copying, temporary arrays, allocation within loops, and repeated container resizing problems located by memory usage and allocation count data), and runtime hotspot locations (located by code segments with concentrated runtime distribution).

[0092] The system identifies optimization opportunities by analyzing the baseline performance dataset: it analyzes type stability diagnostic information to locate code locations of dynamic types, unstable joint types, and inference precision loss as candidate points for type stability optimization; it analyzes memory usage and allocation frequency data, and combines the first run time distribution to locate memory allocation hotspots and identify memory allocation problems such as slice copying, allocation within loops, and repeated container expansion; and it analyzes the median run time distribution to locate code segments with concentrated run times as run hotspots.

[0093] Step S52: Based on the optimization opportunity, call the local optimization skill library to generate an optimization strategy. The local optimization skill library includes performance code pattern rules, best practice rules for memory allocation, type stability diagnosis rules, runtime hotspot sampling rules, and performance before and after comparison rules. Specifically, the system generates optimization strategies by invoking corresponding rules from the local optimization skill library for each type of optimization opportunity: For type stability optimization candidate points, it invokes type stability diagnostic rules to generate strategies that concretize container and loop state types and add function barriers to isolate dynamic logic; for memory allocation issues, it invokes best practice rules for memory allocation to generate strategies such as removing redundant copies or forcing collection, using views to avoid slice copying, changing repeated temporary arrays to fused expressions or explicit loops, and pre-allocating and reusing working buffers; for runtime hotspots, it invokes runtime hotspot sampling rules and performance code pattern rules to generate strategies that add narrow-range fast paths for common input patterns and evaluate parallel execution on independent and sufficiently large hot loops. When multiple optimization opportunities exist simultaneously, optimization strategies are generated by combining them according to the priority order of type stability optimization, memory allocation optimization, and runtime hotspot optimization.

[0094] Step S53: Determine the code location and modification method to be modified according to the optimization strategy, and modify the implementation code of the target function in the source code directory based on the code location and the modification method to obtain the modified target source code file.

[0095] Based on the optimization strategy, the location and method of code to be modified are determined, and the implementation code of the target function is directly modified in the source code directory. Specifically, the optimization execution module performs corresponding code transformation operations according to the modification method: replacing redundant copy or forced collection operations with view references or in-situ modifications; changing repeated temporary array allocations within loops to pre-allocation outside the loop and reuse within the loop; materializing dynamic types through type assertions or function barriers; and adding fast path branches for common input patterns. After the modification is completed, the optimization execution module records the specific content of the optimization strategy applied in this modification, the scope of the modified code lines, and a description of the modification method as a modification record. The modified target source code file and the corresponding modification record serve as one of the sources of content for the optimization report.

[0096] In this embodiment, optimization opportunities based on type, memory, and hotspots are automatically identified using a baseline dataset. The skill library is then invoked according to priority to generate targeted strategies and precisely modify the code. The effect is that it eliminates the need for human experience-based judgment, making optimization solutions traceable and operations auditable, significantly improving the rationality of code modifications and engineering efficiency.

[0097] This application also provides a specified function optimization device, please refer to... Figure 4 The specified function optimization device includes: The function library structure parsing module 10 is used to receive the name of the function to be optimized and parse the source code directory, test directory and performance benchmark directory of the professional toolbox function library; Function location module 20 is used to locate the target function corresponding to the name of the function to be optimized in the source code directory, and obtain a set of source code file paths to be optimized; Mapping module 30 is used to generate a test file list and a performance benchmark test case list based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory, respectively. The baseline management module 40 is used to create a pre-optimization baseline, and run the test file list and the performance benchmark test case list in the state of the pre-optimization baseline to obtain the baseline performance dataset; The optimization execution module 50 is used to generate an optimization strategy based on the baseline performance dataset and a pre-built local optimization skill library, and modify the implementation code of the target function in the source code directory according to the optimization strategy to obtain the modified target source code file.

[0098] The specified function optimization apparatus provided in this application, employing the specified function optimization method in the above embodiments, can solve the technical problem of specified function optimization. Compared with the prior art, the beneficial effects of the specified function optimization apparatus provided in this application are the same as those of the specified function optimization method provided in the above embodiments, and other technical features in the specified function optimization apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0099] This application provides a specified function optimization device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the specified function optimization method in Embodiment 1 above.

[0100] The following is for reference. Figure 5 This document illustrates a structural diagram of a device suitable for implementing the specified function optimization embodiments of this application. The specified function optimization device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The specified function optimization device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0101] like Figure 5As shown, the specified function optimization device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in read-only memory 1002 or a program loaded from storage device 1003 into random access memory 1004. Random access memory 1004 also stores various programs and data required for the operation of the specified function optimization device. The processing unit 1001, read-only memory 1002, and random access memory 1004 are interconnected via bus 1005. Input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to input / output interface 1006: input devices 1007 including, for example, touch screens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the specified function optimization device to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows specified function optimization devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.

[0102] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0103] The specified function optimization device provided in this application, employing the specified function optimization method in the above embodiments, can solve the technical problem of specified function optimization. Compared with the prior art, the beneficial effects of the specified function optimization device provided in this application are the same as those of the specified function optimization method provided in the above embodiments, and other technical features in the specified function optimization device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.

[0104] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0105] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0106] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the specified function optimization method in the above embodiments.

[0107] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0108] The aforementioned computer-readable storage medium may be included in the specified function-optimized device; or it may exist independently and not assembled into the specified function-optimized device.

[0109] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by a designated function optimization device, the designated function optimization device: receives the name of the function to be optimized; parses the source code directory, test directory, and performance benchmark directory of the professional toolbox function library; locates the target function corresponding to the name of the function to be optimized in the source code directory, obtaining a set of source code file paths to be optimized; generates a test file list and a performance benchmark test case list based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory, respectively; creates a pre-optimization baseline; runs the test file list and the performance benchmark test case list in the state of the pre-optimization baseline, obtaining a baseline performance dataset; generates an optimization strategy based on the baseline performance dataset and a pre-built local optimization skill library; and modifies the implementation code of the target function in the source code directory according to the optimization strategy, obtaining the modified target source code file.

[0110] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0111] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0112] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0113] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the specified function optimization method described above, and is capable of solving the technical problem of the specified function optimization. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the specified function optimization method provided in the above embodiments, and will not be repeated here.

[0114] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the specified function optimization method as described above.

[0115] The computer program product provided in this application can solve the technical problem of optimizing a specified function. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the specified function optimization method provided in the above embodiments, and will not be repeated here.

[0116] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A method for optimizing a specified function, characterized in that, The specified function optimization method is applied to the professional toolbox function library, and the specified function optimization method includes: Receive the name of the function to be optimized and parse the source code directory, test directory, and performance benchmark directory of the professional toolbox function library; Locate the target function corresponding to the name of the function to be optimized in the source code directory to obtain the set of source code file paths to be optimized. Based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory, generate a test file list and a performance benchmark test case list, respectively. Create a baseline before optimization, and run the test file list and the performance benchmark test case list under the state of the baseline before optimization to obtain the baseline performance dataset; An optimization strategy is generated based on the baseline performance dataset and a pre-built local optimization skill library. The implementation code of the objective function is then modified in the source code directory according to the optimization strategy to obtain the modified objective source code file.

2. The specified function optimization method as described in claim 1, characterized in that, The step of modifying the implementation code of the target function in the source code directory according to the optimization strategy to obtain the modified target source code file further includes: Rerun the test file list and the performance benchmark test case list based on the modified target source code file to obtain the optimized performance dataset; Perform a retain or rollback decision based on the optimized performance dataset and the baseline performance dataset; The final source code state of the objective function is determined by the retention decision or the rollback decision; An optimization report and performance comparison file are generated based on the final source code status.

3. The specified function optimization method as described in claim 1, characterized in that, The steps for parsing the source code directory, test directory, and performance benchmark directory of the professional toolbox function library include: Read the project configuration file of the professional toolbox function library, and identify the root directory path of the professional toolbox function library based on the project configuration file; The source code directory, the test directory, and the performance benchmark directory are read based on the root directory path.

4. The specified function optimization method as described in claim 1, characterized in that, The step of locating the target function corresponding to the name of the function to be optimized in the source code directory and obtaining the set of source code file paths to be optimized includes: Search the source code directory for a target function that matches the name of the function to be optimized. Identify the function definition and function method corresponding to the target function, and check whether the target function is exported from the toolbox entry file of the professional toolbox function library; If the target function is not exported from the toolbox entry file of the professional toolbox function library, then the target function is marked as an internal function; In the presence of multiple function methods, a set of methods related to the target load is selected from the multiple function methods; Record the source code file paths corresponding to the method set as the source code file path set to be optimized.

5. The specified function optimization method as described in claim 4, characterized in that, The steps of generating a test file list and a performance benchmark test case list based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory respectively include: Obtain the relative path of each source file in the set of source file paths to be optimized, and replace the source directory prefix in the relative path with the test directory prefix based on the test directory to generate candidate test file paths; A list of test files is generated based on the candidate paths of the test files; Locate the performance test folder in the performance benchmark directory that corresponds to the name of the function to be optimized or the source code level in the set of source code file paths to be optimized. Run the performance test folder to generate a list of performance benchmark test cases.

6. The specified function optimization method as described in claim 1, characterized in that, The steps of creating a pre-optimization baseline, running the test file list and the performance benchmark test case list in the state of the pre-optimization baseline, and obtaining the baseline performance dataset include: Create a baseline before optimization when the aforementioned professional toolbox function library is located in a version control repository; Run the test cases in the test file list in the state before optimization to perform correctness verification; Execute type inference diagnostic command; Run the performance test cases in the performance benchmark test case list to perform performance measurements; The baseline performance dataset is determined by performing correctness verification, executing type inference diagnostic commands, and executing performance measurements.

7. The specified function optimization method as described in claim 1, characterized in that, The steps of generating an optimization strategy based on the baseline performance dataset and a pre-built local optimization skill library, and modifying the implementation code of the objective function in the source code directory according to the optimization strategy to obtain the modified target source code file include: Analyze the baseline performance dataset to identify optimization opportunities; Based on the optimization opportunity, the local optimization skill library is invoked to generate optimization strategies. The local optimization skill library includes performance code pattern rules, best practice rules for memory allocation, type stability diagnosis rules, runtime hotspot sampling rules, and performance before and after comparison rules. Based on the optimization strategy, the code location and modification method to be modified are determined. Based on the code location and modification method, the implementation code of the target function is modified in the source code directory to obtain the modified target source code file.

8. A specified function optimization apparatus, characterized in that, The specified function optimization device includes: The function library structure parsing module is used to receive the name of the function to be optimized and parse the source code directory, test directory, and performance benchmark directory of the professional toolbox function library; The function location module is used to locate the target function corresponding to the name of the function to be optimized in the source code directory, and obtain the set of source code file paths to be optimized. The mapping module is used to generate a test file list and a performance benchmark test case list based on the set of source code file paths to be optimized, the test directory, and the performance benchmark directory, respectively. The baseline management module is used to create a pre-optimization baseline, and run the test file list and the performance benchmark test case list in the state of the pre-optimization baseline to obtain the baseline performance dataset; The optimization execution module is used to generate an optimization strategy based on the baseline performance dataset and a pre-built local optimization skill library, and modify the implementation code of the target function in the source code directory according to the optimization strategy to obtain the modified target source code file.

9. A specified function optimization device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the specified function optimization method as described in any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the specified function optimization method as described in any one of claims 1 to 7.