Automatic code cutting method and system
Through the automated code cutting method, useless subdirectories are identified and deleted, which solves the problem of waste of storage resources and logical complexity caused by useless code, and improves development efficiency.
Patent Information
- Application Number
- CN202410829604.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-27
AI Technical Summary
During the software development process, huge useless code leads to a waste of hardware storage resources, and the complex project structure misleads developers to understand the code logic, affecting development efficiency.
Provide an automated code cutting method by obtaining the project directory, traversing subdirectories, deleting useless subdirectories and their files based on preset conditions, and judging whether they are actually involved in compilation through the compilation results. If they are useless, delete them, and restore them if they participate in the compilation successfully. .
It improves the efficiency of code cutting, liberates labor, reduces the waste of hardware storage resources, simplifies code logic, and improves development efficiency.
Smart Images

Figure CN118708221A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of code cutting, and more specifically, to an automatic code cutting method and system. Background Art
[0002] With the advent of the digital age, the scale of software code projects is getting larger and larger, and there are more and more files and directories. In the process of software development and compilation, it is often necessary to deal with complex project structures containing multiple subdirectories. These subdirectories may contain source code, header files, library files, and other resources required for compilation. However, in the actual compilation process, not all subdirectories are required, or some subdirectories may not need to be compiled due to dependencies, configuration options, or platform differences. As a result, there are many similar code directories, files, and functions that do not participate in the compilation in the project, which often misleads developers to understand the code logic and affects development efficiency. At the same time, the huge amount of useless code will also waste hardware storage resources. Therefore, it is necessary to propose a new code reduction method to solve this problem in the actual development process. Summary of the invention
[0003] In view of the above problems, an object of the present invention is to provide an automatic code cutting method and system, which can improve the efficiency of code cutting.
[0004] A first aspect of the present invention provides an automatic code cutting method, comprising:
[0005] Get the project directory to be cut;
[0006] Traverse the project directory to be trimmed and obtain a list of all subdirectories;
[0007] Based on the preset loop conditions, select subdirectories in order and delete the currently selected subdirectory and all its files;
[0008] Compile the project with the subdirectory and all its files deleted to get the second compilation result;
[0009] Determine whether the currently deleted subdirectory and all its files participate in the compilation based on the second compilation result. If the second compilation fails or there is a critical error, the corresponding subdirectory participates in the compilation and the subdirectory and all its files are restored.
[0010] If the second compilation is successful, it is determined whether to delete the subdirectory based on a preset feature threshold.
[0011] In this solution, the step of obtaining the project directory to be cut specifically includes:
[0012] Get the target project;
[0013] Based on the preset compilation system, the target project is compiled. If the target project cannot be compiled normally, a warning message corresponding to the target project is generated;
[0014] Based on the warning information of the corresponding target project, stop the target project;
[0015] If the target project can be compiled normally, the project directory in the corresponding target project is extracted, and the project directory is set as the project directory to be cut.
[0016] In this solution, after obtaining the list of all subdirectories, the following steps are included:
[0017] Extract directory keywords from subdirectories;
[0018] Compare and analyze the directory keywords with the keywords in the preset whitelist records to obtain the same keywords;
[0019] Extract the number and position of occurrences of the same keyword in the subdirectory;
[0020] Based on the number and position of the same keyword in the subdirectory, the trust index corresponding to the same keyword is obtained;
[0021] When the trust index of the same keyword is greater than or equal to the preset trust index threshold, the subdirectory where the same keyword is located is set as a trusted subdirectory;
[0022] Remove the trusted subdirectory from the subdirectory list.
[0023] In this solution, the step of obtaining the trust index corresponding to the same keyword based on the number and position of the same keyword in the subdirectory specifically includes:
[0024] According to the position where the same keyword appears in the subdirectory, the preset position parameter table is searched to obtain the position trust parameter value corresponding to the same keyword;
[0025] Multiply the location trust parameter value of the same keyword by the preset location trust weight to obtain the location trust index;
[0026] Multiply the number of occurrences of the same keyword in the subdirectory by the preset quantity trust weight to obtain the quantity trust index;
[0027] The position trust index and the quantity trust index are accumulated to obtain the trust index corresponding to the same keyword.
[0028] In this solution, after obtaining the list of all subdirectories, the following is also included:
[0029] Extract the properties of subdirectory files;
[0030] Determine whether the attribute of the sub-directory file meets the preset condition, and if so, mark the corresponding sub-directory file to obtain the marked sub-directory;
[0031] Remove the identified subdirectory from the list of subdirectories.
[0032] In this solution, if the second compilation is successful, the step of determining whether to delete the subdirectory based on a preset feature threshold specifically includes:
[0033] If the target project can be compiled normally, the corresponding compiled feature value is extracted and set as the first compilation feature value;
[0034] If the second compilation is successful, extract the feature value corresponding to the second compilation and set it as the feature value of the second compilation;
[0035] Analyze the first compiled feature value and the second compiled feature value to obtain a feature similarity value;
[0036] If the feature similarity value is greater than or equal to the preset feature threshold, the corresponding subdirectory is set as not participating in the compilation, and the corresponding subdirectory and all its files are deleted;
[0037] If the feature similarity value is less than the preset feature threshold, the corresponding subdirectory is set to participate in the compilation, and the subdirectory and all its files are restored.
[0038] In this solution, the step of analyzing the first compiled feature value and the second compiled feature value to obtain a feature similarity value specifically includes:
[0039] Extracting a reaction time feature value and a memory feature value from the first compilation feature value, and setting them as a first reaction time feature value and a first memory feature value respectively;
[0040] Extracting a reaction time feature value and a memory feature value from the second compilation feature value, and setting them as a second reaction time feature value and a second memory feature value respectively;
[0041] When the first reaction time characteristic value is greater than or equal to the second reaction time characteristic value, the corresponding reaction time similarity value is set to 100%;
[0042] When the first reaction time characteristic value is less than the second reaction time characteristic value, dividing the second reaction time characteristic value by the first reaction time characteristic value to obtain a reaction time similarity value;
[0043] When the first memory similarity value is greater than or equal to the second reaction time characteristic value, the corresponding memory similarity value is set to 100%;
[0044] When the first memory characteristic value is less than the second memory characteristic value, the second memory characteristic value is divided by the first memory characteristic value to obtain a memory similarity value;
[0045] The feature similarity value is the minimum value of the reaction time similarity value and the memory similarity value.
[0046] A second aspect of the present invention provides an automatic code cutting system, comprising a memory and a processor, wherein the memory stores an automatic code cutting method program, and when the automatic code cutting method program is executed by the processor, the following steps are implemented:
[0047] Get the project directory to be cut;
[0048] Traverse the project directory to be trimmed and obtain a list of all subdirectories;
[0049] Based on the preset loop conditions, select subdirectories in order and delete the currently selected subdirectory and all its files;
[0050] Compile the project with the subdirectory and all its files deleted to get the second compilation result;
[0051] Determine whether the currently deleted subdirectory and all its files participate in the compilation based on the second compilation result. If the second compilation fails or there is a critical error, the corresponding subdirectory participates in the compilation and the subdirectory and all its files are restored.
[0052] If the second compilation is successful, it is determined whether to delete the subdirectory based on a preset feature threshold.
[0053] In this solution, the step of obtaining the project directory to be cut specifically includes:
[0054] Get the target project;
[0055] Based on the preset compilation system, the target project is compiled. If the target project cannot be compiled normally, a warning message corresponding to the target project is generated;
[0056] Based on the warning information of the corresponding target project, stop the target project;
[0057] If the target project can be compiled normally, the project directory in the corresponding target project is extracted, and the project directory is set as the project directory to be cut.
[0058] In this solution, after obtaining the list of all subdirectories, the following steps are included:
[0059] Extract directory keywords from subdirectories;
[0060] Compare and analyze the directory keywords with the keywords in the preset whitelist records to obtain the same keywords;
[0061] Extract the number and position of occurrences of the same keyword in the subdirectory;
[0062] Based on the number and position of the same keyword in the subdirectory, the trust index corresponding to the same keyword is obtained;
[0063] When the trust index of the same keyword is greater than or equal to the preset trust index threshold, the subdirectory where the same keyword is located is set as a trusted subdirectory;
[0064] Remove the trusted subdirectory from the subdirectory list.
[0065] The present invention discloses an automatic code cutting method and system. The present invention allows the code cutting work to be handed over to machines, greatly liberates labor, and improves the code cutting efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 A flow chart of an automatic code cutting method of the present invention is shown;
[0067] Figure 2 A block diagram of an automatic code tailoring system of the present invention is shown. DETAILED DESCRIPTION
[0068] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0069] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0070] Figure 1 A flow chart of an automatic code cutting method of the present invention is shown.
[0071] like Figure 1 As shown, the present invention discloses an automatic code cutting method, comprising:
[0072] S101, obtaining a project directory to be cut;
[0073] S102, traverse the project directory to be cut and obtain a list of all subdirectories;
[0074] S103, based on the preset loop condition, select subdirectories in order, and delete the currently selected subdirectory and all files thereof;
[0075] S104, compile the project for deleting the subdirectory and all its files to obtain a second compilation result;
[0076] S105, judging whether the currently deleted subdirectory and all its files participate in the compilation according to the second compilation result, if the second compilation fails or there is a critical error, the corresponding subdirectory participates in the compilation, and the subdirectory and all its files are restored;
[0077] S106: If the second compilation is successful, determine whether to delete the subdirectory based on a preset feature threshold.
[0078] According to an embodiment of the present invention, the project directory to be trimmed is a sub-project in the target project. The required system parameters are configured in advance according to the target project, such as setting the loop conditions in advance. The compilation results include whether the compilation is successful, errors or warning messages during the compilation process, etc. When errors or warning messages occur during the compilation process, the compilation is set to fail or there is a critical error.
[0079] According to an embodiment of the present invention, the step of obtaining the project directory to be clipped specifically includes:
[0080] Get the target project;
[0081] Based on the preset compilation system, the target project is compiled. If the target project cannot be compiled normally, a warning message corresponding to the target project is generated;
[0082] Based on the warning information of the corresponding target project, stop the target project;
[0083] If the target project can be compiled normally, the project directory in the corresponding target project is extracted, and the project directory is set as the project directory to be cut.
[0084] It should be noted that after extracting the target project, it needs to be compiled once to confirm whether the target project can be compiled normally. If it cannot be compiled normally, the work of the target project will be stopped; if the target project can be compiled normally, the target project will be divided into multiple sub-projects, and the names of the sub-projects will be collected and set as the project directory in the corresponding target project.
[0085] According to an embodiment of the present invention, after obtaining the list of all subdirectories, the following steps are included:
[0086] Extract directory keywords from subdirectories;
[0087] Compare and analyze the directory keywords with the keywords in the preset whitelist records to obtain the same keywords;
[0088] Extract the number and position of occurrences of the same keyword in the subdirectory;
[0089] Based on the number and position of the same keyword in the subdirectory, the trust index corresponding to the same keyword is obtained;
[0090] When the trust index of the same keyword is greater than or equal to the preset trust index threshold, the subdirectory where the same keyword is located is set as a trusted subdirectory;
[0091] Remove the trusted subdirectory from the subdirectory list.
[0092] It should be noted that, according to information such as the target file generated by compilation and the generation path of the target file, some whitelist keywords are intelligently added to the preset whitelist; in addition, some certain compiled keywords can also be manually added to the preset whitelist.
[0093] According to an embodiment of the present invention, the step of obtaining the trust index corresponding to the same keyword based on the number and position of the same keyword in the sub-directory specifically includes:
[0094] According to the position where the same keyword appears in the subdirectory, the preset position parameter table is searched to obtain the position trust parameter value corresponding to the same keyword;
[0095] Multiply the location trust parameter value of the same keyword by the preset location trust weight to obtain the location trust index;
[0096] Multiply the number of occurrences of the same keyword in the subdirectory by the preset quantity trust weight to obtain the quantity trust index;
[0097] The position trust index and the quantity trust index are accumulated to obtain the trust index corresponding to the same keyword.
[0098] It should be noted that the preset position parameter table stores the position trust parameter values corresponding to the same keyword in different positions. For example, the position trust parameter value corresponding to the same keyword in the title is 1, the position trust parameter value corresponding to the same keyword in the sub-directory file is set to 0.5, etc. The preset position trust weight and the preset quantity trust weight are both values greater than 0.
[0099] According to an embodiment of the present invention, after obtaining the list of all subdirectories, the method further includes:
[0100] Extract the properties of subdirectory files;
[0101] Determine whether the attribute of the sub-directory file meets the preset condition, and if so, mark the corresponding sub-directory file to obtain the marked sub-directory;
[0102] Remove the identified subdirectory from the list of subdirectories.
[0103] It should be noted that some trimming restrictions are added, and the attributes of the sub-directory file include modification time attribute, code line number attribute, file suffix .h, etc. The preset conditions include necessary file information in the target project, such as time conditions, etc.
[0104] According to an embodiment of the present invention, if the second compilation is successful, the step of determining whether to delete the subdirectory based on a preset feature threshold specifically includes:
[0105] If the target project can be compiled normally, the corresponding compiled feature value is extracted and set as the first compilation feature value;
[0106] If the second compilation is successful, extract the feature value corresponding to the second compilation and set it as the feature value of the second compilation;
[0107] Analyze the first compiled feature value and the second compiled feature value to obtain a feature similarity value;
[0108] If the feature similarity value is greater than or equal to the preset feature threshold, the corresponding subdirectory is set as not participating in the compilation, and the corresponding subdirectory and all its files are deleted;
[0109] If the feature similarity value is less than the preset feature threshold, the corresponding subdirectory is set to participate in the compilation, and the subdirectory and all its files are restored.
[0110] It should be noted that, in order to solve the problem that the second compilation is successful but there is a big gap in the running dynamics, the feature values of the first compilation are compared with the feature values of the second compilation, and the feature threshold is set for judgment, so as to further optimize the code tailoring.
[0111] According to an embodiment of the present invention, the step of analyzing the first compiled feature value and the second compiled feature value to obtain a feature similarity value specifically includes:
[0112] Extracting a reaction time feature value and a memory feature value from the first compilation feature value, and setting them as a first reaction time feature value and a first memory feature value respectively;
[0113] Extracting a reaction time feature value and a memory feature value from the second compilation feature value, and setting them as a second reaction time feature value and a second memory feature value respectively;
[0114] When the first reaction time characteristic value is greater than or equal to the second reaction time characteristic value, the corresponding reaction time similarity value is set to 100%;
[0115] When the first reaction time characteristic value is less than the second reaction time characteristic value, dividing the second reaction time characteristic value by the first reaction time characteristic value to obtain a reaction time similarity value;
[0116] When the first memory similarity value is greater than or equal to the second reaction time characteristic value, the corresponding memory similarity value is set to 100%;
[0117] When the first memory characteristic value is less than the second memory characteristic value, the second memory characteristic value is divided by the first memory characteristic value to obtain a memory similarity value;
[0118] The feature similarity value is the minimum value of the reaction time similarity value and the memory similarity value.
[0119] It should be noted that the feature similarity values include reaction time similarity values and memory similarity values. The reaction time is the time difference between the completion time and the start time of compiling the project for deleting the subdirectory and all its files, and the memory is the memory after compiling the project for deleting the subdirectory and all its files.
[0120] According to an embodiment of the present invention, it also includes:
[0121] When a subdirectory participates in compilation;
[0122] Split the subdirectories involved in compilation to obtain secondary subdirectories;
[0123] Based on the preset loop conditions, select the secondary subdirectories in order and delete the currently selected secondary subdirectory and all its files;
[0124] Compile the project that deletes the secondary subdirectory and all its files to obtain the compilation result of the secondary subdirectory;
[0125] According to the compilation result of the secondary subdirectory, determine whether the currently deleted secondary subdirectory and all its files participate in the compilation. If the compilation of the secondary subdirectory fails or there is a critical error, the corresponding secondary subdirectory participates in the compilation, the secondary subdirectory and all its files are restored, and the secondary subdirectory participating in the compilation is obtained;
[0126] Then split the second-level subdirectories involved in the compilation to obtain third-level subdirectories, and then select the third-level subdirectories to delete in turn, and determine the compilation results until the n-level subdirectories cannot be split;
[0127] If the second compilation is successful, it is determined whether to delete the secondary subdirectory based on a preset feature threshold.
[0128] Figure 2 A block diagram of an automatic code tailoring system of the present invention is shown.
[0129] like Figure 2As shown, the second aspect of the present invention provides an automatic code cutting system 2, comprising a memory 21 and a processor 22, wherein the memory stores an automatic code cutting method program, and when the automatic code cutting method program is executed by the processor, the following steps are implemented:
[0130] Get the project directory to be cut;
[0131] Traverse the project directory to be trimmed and obtain a list of all subdirectories;
[0132] Based on the preset loop conditions, select subdirectories in order and delete the currently selected subdirectory and all its files;
[0133] Compile the project with the subdirectory and all its files deleted to get the second compilation result;
[0134] Determine whether the currently deleted subdirectory and all its files participate in the compilation based on the second compilation result. If the second compilation fails or there is a critical error, the corresponding subdirectory participates in the compilation and the subdirectory and all its files are restored.
[0135] If the second compilation is successful, it is determined whether to delete the subdirectory based on a preset feature threshold.
[0136] In this solution, the step of obtaining the project directory to be cut specifically includes:
[0137] Get the target project;
[0138] Based on the preset compilation system, the target project is compiled. If the target project cannot be compiled normally, a warning message corresponding to the target project is generated;
[0139] Based on the warning information of the corresponding target project, stop the target project;
[0140] If the target project can be compiled normally, the project directory in the corresponding target project is extracted, and the project directory is set as the project directory to be cut.
[0141] In this solution, after obtaining the list of all subdirectories, the following steps are included:
[0142] Extract directory keywords from subdirectories;
[0143] Compare and analyze the directory keywords with the keywords in the preset whitelist records to obtain the same keywords;
[0144] Extract the number and position of occurrences of the same keyword in the subdirectory;
[0145] Based on the number and position of the same keyword in the subdirectory, the trust index corresponding to the same keyword is obtained;
[0146] When the trust index of the same keyword is greater than or equal to the preset trust index threshold, the subdirectory where the same keyword is located is set as a trusted subdirectory;
[0147] Remove the trusted subdirectory from the subdirectory list.
[0148] The present invention discloses an automatic code tailoring method and system, wherein the method comprises: obtaining a project directory to be tailored; traversing the project directory to be tailored to obtain a list of all subdirectories; selecting subdirectories in sequence based on preset loop conditions, and deleting the currently selected subdirectory and all its files; compiling the project from which the subdirectory and all its files are deleted to obtain a second compilation result; judging whether the currently deleted subdirectory and all its files participate in the compilation according to the second compilation result, if the second compilation fails or there is a critical error, the corresponding subdirectory participates in the compilation, and the subdirectory and all its files are restored; if the second compilation succeeds, determining whether to delete the subdirectory based on a preset feature threshold. The present invention allows the code tailoring work to be handed over to the machine, greatly liberating labor and improving the efficiency of code tailoring.
[0149] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0150] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0151] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0152] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks or optical disks, and other media that can store program codes.
[0153] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
Claims
1. An automatic code cutting method, characterized in that: include: Get the project directory to be cut; Traverse the project directory to be trimmed and obtain a list of all subdirectories; Based on the preset loop conditions, select subdirectories in order and delete the currently selected subdirectory and all its files; Compile the project with the subdirectory and all its files deleted to get the second compilation result; Determine whether the currently deleted subdirectory and all its files participate in the compilation based on the second compilation result. If the second compilation fails or there is a critical error, the corresponding subdirectory participates in the compilation and the subdirectory and all its files are restored. If the second compilation is successful, it is determined whether to delete the subdirectory based on a preset feature threshold.
2. The automatic code cutting method according to claim 1, characterized in that: The step of obtaining the project directory to be cut specifically includes: Get the target project; Based on the preset compilation system, the target project is compiled. If the target project cannot be compiled normally, a warning message corresponding to the target project is generated; Based on the warning information of the corresponding target project, stop the target project; If the target project can be compiled normally, the project directory in the corresponding target project is extracted, and the project directory is set as the project directory to be cut.
3. The automatic code cutting method according to claim 1, characterized in that: After obtaining the list of all subdirectories, it includes: Extract directory keywords from subdirectories; Compare and analyze the directory keywords with the keywords in the preset whitelist records to obtain the same keywords; Extract the number and position of occurrences of the same keyword in the subdirectory; Based on the number and position of the same keyword in the subdirectory, the trust index corresponding to the same keyword is obtained; When the trust index of the same keyword is greater than or equal to the preset trust index threshold, the subdirectory where the same keyword is located is set as a trusted subdirectory; Remove the trusted subdirectory from the subdirectory list.
4. The automatic code cutting method according to claim 3, characterized in that: The step of obtaining the trust index corresponding to the same keyword based on the number and position of the same keyword in the subdirectory specifically includes: According to the position where the same keyword appears in the subdirectory, the preset position parameter table is searched to obtain the position trust parameter value corresponding to the same keyword; Multiply the location trust parameter value of the same keyword by the preset location trust weight to obtain the location trust index; Multiply the number of occurrences of the same keyword in the subdirectory by the preset quantity trust weight to obtain the quantity trust index; The position trust index and the quantity trust index are accumulated to obtain the trust index corresponding to the same keyword.
5. The automatic code cutting method according to claim 3, characterized in that: After obtaining the list of all subdirectories, the following is also included: Extract the properties of subdirectory files; Determine whether the attribute of the sub-directory file meets the preset condition, and if so, mark the corresponding sub-directory file to obtain the marked sub-directory; Remove the identified subdirectory from the list of subdirectories.
6. The automatic code cutting method according to claim 1, characterized in that: If the second compilation is successful, the step of determining whether to delete the subdirectory based on a preset feature threshold specifically includes: If the target project can be compiled normally, the corresponding compiled feature value is extracted and set as the first compilation feature value; If the second compilation is successful, extract the feature value corresponding to the second compilation and set it as the feature value of the second compilation; Analyze the first compiled feature value and the second compiled feature value to obtain a feature similarity value; If the feature similarity value is greater than or equal to the preset feature threshold, the corresponding subdirectory is set as not participating in the compilation, and the corresponding subdirectory and all its files are deleted; If the feature similarity value is less than the preset feature threshold, the corresponding subdirectory is set to participate in the compilation, and the subdirectory and all its files are restored.
7. The automatic code cutting method according to claim 6, characterized in that: The step of analyzing the first compiled feature value and the second compiled feature value to obtain a feature similarity value specifically includes: Extracting a reaction time feature value and a memory feature value from the first compilation feature value, and setting them as a first reaction time feature value and a first memory feature value respectively; Extracting a reaction time feature value and a memory feature value from the second compilation feature value, and setting them as a second reaction time feature value and a second memory feature value respectively; When the first reaction time characteristic value is greater than or equal to the second reaction time characteristic value, the corresponding reaction time similarity value is set to 100%; When the first reaction time characteristic value is less than the second reaction time characteristic value, dividing the second reaction time characteristic value by the first reaction time characteristic value to obtain a reaction time similarity value; When the first memory similarity value is greater than or equal to the second reaction time characteristic value, the corresponding memory similarity value is set to 100%; When the first memory characteristic value is less than the second memory characteristic value, the second memory characteristic value is divided by the first memory characteristic value to obtain a memory similarity value; The feature similarity value is the minimum value of the reaction time similarity value and the memory similarity value.
8. An automated code cutting system, characterized in that: The invention comprises a memory and a processor, wherein the memory stores an automatic code cutting method program, and when the automatic code cutting method program is executed by the processor, the following steps are implemented: Get the project directory to be cut; Traverse the project directory to be trimmed and obtain a list of all subdirectories; Based on the preset loop conditions, select subdirectories in order and delete the currently selected subdirectory and all its files; Compile the project with the subdirectory and all its files deleted to get the second compilation result; Determine whether the currently deleted subdirectory and all its files participate in the compilation based on the second compilation result. If the second compilation fails or there is a critical error, the corresponding subdirectory participates in the compilation and the subdirectory and all its files are restored. If the second compilation is successful, it is determined whether to delete the subdirectory based on a preset feature threshold.
9. The automatic code cutting system according to claim 8, characterized in that: The step of obtaining the project directory to be cut specifically includes: Get the target project; Based on the preset compilation system, the target project is compiled. If the target project cannot be compiled normally, a warning message corresponding to the target project is generated; Based on the warning information of the corresponding target project, stop the target project; If the target project can be compiled normally, the project directory in the corresponding target project is extracted, and the project directory is set as the project directory to be cut.
10. The automatic code cutting system according to claim 8, characterized in that: After obtaining the list of all subdirectories, it includes: Extract directory keywords from subdirectories; Compare and analyze the directory keywords with the keywords in the preset whitelist records to obtain the same keywords; Extract the number and position of occurrences of the same keyword in the subdirectory; Based on the number and position of the same keyword in the subdirectory, the trust index corresponding to the same keyword is obtained; When the trust index of the same keyword is greater than or equal to the preset trust index threshold, the subdirectory where the same keyword is located is set as a trusted subdirectory; Remove the trusted subdirectory from the subdirectory list.
