Disclosure of Invention
Aiming at the problems in the related art, the invention provides a code segment extraction iteration using method and a code segment extraction iteration using system based on parallelization, so as to overcome the technical problems in the prior art.
In order to solve the technical problems, the invention is realized by the following technical scheme:
the invention relates to a code segment extraction iteration using method based on parallelization, which comprises the following steps:
s1, acquiring a code fragment function, generating a code fragment function calling time duty ratio matrix, classifying the code fragment function calling time duty ratio matrix by using a K neighbor method to obtain a code fragment hot spot function, and marking the code fragment hot spot function as a first code extraction iteration condition;
s2, measuring the running quality of the code segments by using the time complexity of the objective function in the code segments and the running time of the code segments in the program, and optimizing the running time of the code segments in the program by using a black-fin iris optimization algorithm to obtain optimized code segments;
S3, generating a character string matrix according to the optimized code segments, detecting the similarity of character strings in the character string matrix, removing code segments with similar features to obtain similarity code segments, and marking the similarity code segments as second code extraction iteration conditions;
s4, combining the first code extraction iteration condition and the second code extraction iteration condition to obtain a code segment to be processed, operating the code segment to be processed, adjusting the parallel threads, optimizing the code segment operation efficiency based on a differential creative search algorithm, and realizing code segment extraction iteration.
The method comprises the steps of firstly obtaining a code fragment function, calculating the calling time duty ratio of the code fragment function, recording the calling time duty ratio as a condition for selecting a hot function, classifying the code fragment function calling time duty ratio matrix by using a K nearest neighbor method to obtain a code fragment hot function, recording the code fragment hot function as a first code extraction iteration condition, secondly measuring the running quality of the code fragment by using the target function time complexity in the code fragment and the running time of the code fragment in a program, obtaining the target function time complexity by using the target function calling relation, optimizing the running time of the code fragment in the program by using a black-fin iris optimization algorithm to obtain the optimal running time, obtaining the optimal position by changing the hunting and migration positions of the black-fin iris, wherein the algorithm has strong evolutionary capability, high searching speed and strong optimizing capability, converting character strings in the code fragment into character string feature vectors, calculating the similarity of the character string feature vectors, distinguishing whether the character strings are repeated, deleting the repeated character strings to obtain the similarity code fragment, setting the similarity as a second code extraction condition, optimizing the running time of the code fragment by using the target function time complexity and the target function calling relation, optimizing the running time of the code fragment in the program to obtain the optimal running time, optimizing the best running time by using the black-fin iris optimization algorithm, optimizing the running time in the program, optimizing the code iteration condition, optimizing the running algorithm, optimizing the running efficiency by adding the iteration condition to the code fragment, and optimizing the iteration condition, and optimizing the algorithm, and optimizing the running efficiency, and optimizing the algorithm, and the algorithm according to the iteration condition, and optimizing the iteration code algorithm, and the algorithm.
Preferably, the step S1 includes the steps of:
S11, acquiring a code fragment function, calculating the calling time duty ratio of the code fragment function to obtain a code fragment function calling time duty ratio set, and recording asWhereinRepresent the firstSetting the feature dimension of the code segment function calling time ratio in the code segment function calling time ratio set as the code segment function calling time ratioGenerating code fragment function call time duty ratio matrixAs will be described below,
,
Wherein,Representing the code fragment function call time in the duty cycle matrixThe dimension of each feature isThe code fragment function call time duty cycle of (a);
Setting a comparison code fragment function set, calculating the calling time duty ratio of the comparison code fragment function in the comparison code fragment function set in the comparison code fragment to obtain a comparison code fragment function time duty ratio set, selecting a list of the code fragment function calling time duty ratio set marked as a first code fragment function calling time duty ratio set from the code fragment function calling time duty ratio matrixWhereinRepresenting the code fragment function call time in the duty cycle matrixThe dimension of each feature isThe code fragment function call time duty cycle of (a);
s12, setting a similarity threshold asSelecting the comparison code segment function time duty ratio set to be larger thanAccording to the similarity of the sample data of the first code fragment function calling time duty ratio set and the second code fragment function calling time duty ratio set, marking the code fragment function calling time duty ratio corresponding to the minimum similarity as a nearby point to obtain a nearby point setWhereinRepresent the firstA plurality of adjacent points;
Setting upRepresentative coefficients representing neighboring points in the set of neighboring points,Representative coefficients representing the code fragment function call time duty cycles in the first set of code fragment function call time duty cycles,The weight is represented by a weight that,Representing classification function and taking 1 when the data sample corresponding to the minimum similarity value is in the first code fragment function calling time duty ratio set, otherwise taking 0, calculating the weight of the adjacent point in the adjacent point setThe calculation formula is as follows,
Wherein,Weights representing the neighboring points in the set of neighboring points,Representing the first of a set of nearby pointsThe representative coefficients of the individual neighboring points are,;
Calculating to obtain the weight value of the adjacent point in the adjacent point set, selecting the maximum value of the weight value of the adjacent point in the adjacent point set, obtaining sample data of a first code fragment function call time duty ratio set of the adjacent point corresponding to the maximum value of the weight value of the adjacent point in the adjacent point set, recording the sample data as the code fragment function call time duty ratio to be classified, forming the code fragment function call time duty ratio set according to the code fragment function call time duty ratio to be classified, finding a code fragment function corresponding to the code fragment function call time duty ratio in the code fragment function call time duty ratio set, recording the code fragment hotspot function as a code fragment hotspot function, and recording the code fragment hotspot function as a first code extraction iteration condition.
According to the method, the code fragment function is obtained, the calling time proportion of the code fragment function is calculated, the calling time proportion is used as a condition for selecting the popular function, the representative coefficient of the calling time proportion of the code fragment function is obtained by using a K neighbor method, the code fragment function calling time proportion set is classified, the code fragment hot spot function is obtained, and the code fragment hot spot function is recorded as a first code extraction iteration condition.
Preferably, the step S2 includes the steps of:
S21, the set code segment comprisesObtaining an objective function set asWhereinRepresent the firstSelecting an objective function in the objective function setAs an initial function, generating a directed graph according to the calling relation of the initial functionInto contiguous linked lists, whereRepresenting a call relationship set;
the calling relation set for setting the initial function comprisesObtaining an atomic function set asWhereinRepresent the firstThe time complexity calculation process of the atomic functions in the atomic function set is as follows:
s211, setting the loop body set asWhereinRepresent the firstThe number of the cyclic variables is a function of,
When the number of times of changing the circulation variable in the circulation body set is any constant, the time complexity of the circulation variable in the circulation body set isWhen the number of the circulation variable changes in the circulation body set is recorded as an indefinite itemAt this time, the time complexity of the cyclic variables in the cyclic volume set isWhen the number of the circulation variable changes in the circulation body set is recorded as an indefinite itemAnd the change of the circulation variable in the circulation body set is enlarged by 2 times, at the moment, the time complexity of the circulation variable in the circulation body set isCompleting judgment of the circulation variables in the circulation body set;
S212, setting the loop body nesting set asWhereinRepresent the firstA loop body nested relationship when loop variables in the loop body setAndSatisfying the cyclic body nesting relationship in the cyclic body nesting set, and circulating variables in the cyclic body setIs an outer layer circulation, whereinAndRespectively represent the firstAndThe time complexity of the cyclic variables in the cyclic volume set isSetting a basic sentence cyclic body execution sentence set, selecting the maximum frequency execution sentence in the basic sentence cyclic body execution sentence set, wherein the maximum frequency execution sentence time complexity in the basic sentence cyclic body execution sentence setThe atomic functions in the atomic function set compriseExecuting statement set by a basic statement loop body to obtain the statement setThe maximum frequency execution statement in the set of execution statements of the basic statement loop body, the time complexity of the atomic function in the set of atomic functions;
S22, after obtaining the time complexity of the atomic function in the atomic function set, performing backtracking operation on the atomic function in the atomic function set according to S211 and S212 to obtain the time complexity of the initial function, calculating to obtain the time complexity of the objective function in the code segment, generating the time complexity set of the objective function in the code segment, and setting the time complexity threshold as followsDiscarding the code segment having an objective function time complexity set greater thanObtaining a processed code segment;
s23, setting the target function set of the processed code segment asWhereinRepresent the firstObjective function, the characteristic dimension of the objective function is as followsGenerating an objective function matrix of a code segmentAs will be described below,
,
Wherein,Represent the firstThe dimension of each feature isIs a target function of (2);
optimizing code segment running time in program by using black-wing iris optimization algorithm, and setting fitness functionWhereinIndicating the interrupt time of the interrupt service,The execution time of the code segment is indicated,The error time is represented by the following specific procedures:
S231, setting the target function in the target function matrix of the code segment to represent the position of the iris nigricans, wherein the population individuals of the iris nigricans areThe characteristic dimension of the iris nigrum isFirst, theDimension of only featuresThe initial position calculation formula of the iris nigrum is as follows,
Wherein,Represent the firstDimension of only featuresIs used for the initial position of the iris nigrum,Represent the firstIris Tectoria with black wings at the first stageThe upper bound of the dimension is maintained,Represent the firstIris Tectoria with black wings at the first stageThe dimension of the lower bound is maintained,Representing a random number and;
S232, continuously changing the position of the iris nigricans during the process of attacking hunting objects, continuously optimizing the running time of the code fragments in the program, and setting the iris nigricans in the programThe position at the time of iteration isIris nigromaculata (Tex. Nigromaculata) inThe position at the time of iteration isThe maximum iteration number isThe judgment coefficient of the iris nigricans attack hunting object is,Representing a random number and,,Expressed as a constant, the calculation formula is as follows,
,
,
When the iris is atAt location, optimizing the run-time of the code segment in the program completes the firstIterating for the second time;
S233, introducing a iris nigricans leader in the migration process, and setting population fitness of the iris nigricans asWhen the current fitness isGreater thanWhen the population of the iris nigricans is migrated, the population of the iris nigricans is led by a leader of the iris nigricans, and the migration process is setThe position at the time of iteration isDuring migrationThe position at the time of iteration isThe migration process coefficient of the iris nigricans isThe cauchy distribution function isThe position of the iris nigromaculata leader isRepresenting the running time of the code segment in the program, the calculation formula is as follows,
,
,
And continuously searching the minimum fitness of the iris nigrum in the migration process, setting the current iteration times, stopping iteration when the current iteration times are larger than the maximum iteration times, and completing the optimization of the running time of the code segment in the program to obtain the optimized code segment.
According to the method, the running quality of the code segments is measured by using the time complexity of the objective function in the code segments and the running time of the code segments in the program, the time complexity of the objective function is obtained by using the target function calling relation, the running time of the code segments in the program is optimized by using the optimization algorithm of the iris nigrum, the optimal position is obtained by changing hunting and migration positions of the iris nigrum, and the algorithm has strong evolutionary capability, high searching speed and strong optimizing capability.
Preferably, the step S3 includes the steps of:
s31, setting the optimized code segment to containA character string, noted asWhereinRepresent the firstCharacter strings, the characteristic dimension of the character strings is as followsObtaining character string matrixAs will be described below,
,
Wherein,Represent the firstThe dimension of each feature isIs a character string of (a);
Converting the character strings in the character string matrix into character string feature vectors, taking 2 character string feature vectors in the character string matrix, and normalizing the 2 character string feature vectors in the character string matrix to obtain normalized vectorsAndThe similarity calculation formula is as follows,
Wherein,Representing the similarity of character strings in the character string matrix;
s32, calculating vector cosine values of 2 character string feature vectors in the character string matrix, and setting a similarity threshold asThe vector cosine value threshold isWhen the vector cosine value of the 2 character string feature vectors in the character string matrix is greater than or equal toAnd the similarity of the character strings in the character string matrix is greater than or equal toWhen the character strings in the character string matrix are the same, deleting the character strings in the same character string matrix, and when the vector cosine value of the feature vectors of 2 character strings in the character string matrix is smaller thanAnd the similarity of the character strings in the character string matrix is smaller thanAnd obtaining a similarity code segment, and marking the similarity code segment as a second code extraction iteration condition.
According to the invention, character strings in the code segments are converted into character string feature vectors, the similarity of the character string feature vectors is calculated, whether the character strings are repeated or not is resolved, the repeated character strings are deleted, a similarity code segment is obtained, the similarity code segment is marked as a second code extraction iteration condition, and a result obtained by using the vector cosine value of the character string feature vectors is more accurate.
Preferably, the step S4 includes the steps of:
S41, a first code extraction iteration condition is a code segment hot spot function, a second code extraction iteration condition is a similarity code segment, the code segment hot spot function is added into the similarity code segment, code segment extraction is completed, a code segment set to be processed is obtained, and the code segment set is recorded asWhereinRepresent the firstSetting the feature dimension of the code segment to be processed asGenerating a code segment matrix to be processedAs will be described below,
,
Wherein,Represent the firstThe dimension of each feature isTo be processed;
Optimizing the parallel threads by using a differential creative search algorithm, realizing optimization of the running efficiency of the code segments to be processed in the code segment matrix to be processed, and setting the code segment matrix to be processedRepresenting the number of problem solutions asProblem solution dimension isThe code segment matrix to be processed is recorded as a problem solution matrix, wherein an individual generation formula in the problem solution matrix is as follows,
Wherein,Representing a random number and,Representing problem solution matrixThe upper bound of the dimension is maintained,Representing problem solution matrixMaintaining a lower bound;
S42, setting fitness functionWhereinIndicating the efficiency of the storage and,The input efficiency is indicated as such,Representing output efficiency, calculating the fitness of the individuals in the problem solution matrix, ranking according to the fitness of the individuals in the problem solution matrix from big to small to obtain ranking numbers, setting the first stage in the differential knowledge acquisition stageThe secondary iteration differential knowledge acquisition rate isFirst, theThe secondary iteration differential knowledge acquisition variable isFirst, theIndividual rank number of the next iterationThe maximum iteration number isThe calculation formula is as follows,
,
,
Setting a first threshold value asWhen the firstThe secondary iteration differential knowledge acquisition variable is smaller thanWhen the individual in the problem solution matrix is selected as the test individual, the test individual is according to the firstLearning, absorbing and integrating new knowledge or experience by iterative differential knowledge acquisition rate, starting to optimize parallel thread number process, setting the firstThe individual positions of the iterative tests are as followsFirst, theIndividual locations in the sub-iteration problem solution matrix areThen (1)The individual position calculation formula in the sub-iteration problem solution matrix is as follows,
After the individual positions in the problem solution matrix are replaced, a new problem solution matrix is obtained, and the process of optimizing the number of parallel threads is completedIterating for the second time;
S43, introducing a team leader in a convergence thinking stage, wherein the position of the team leader meets the maximum fitness function, and the running efficiency of the code segments to be processed in the code segment matrix to be processed is the best at the momentThe position of the secondary iteration team leader isThe individual positions in the new problem solution matrix are selected as followsAndFirst, theThe secondary iteration coefficients are respectively、AndThe maximum iteration number isThe individual location update calculation formula in the new problem solution matrix is as follows,
,
,
Coefficients ofContinuously adjusting the position of the team leader, and setting the current iteration number and a second threshold valueWhen the current iteration number is equal to the maximum iteration number and the individual position in the new problem solution matrix is smaller thanObtaining the position of the team leader when the current iteration number is equal to the maximum iteration number, otherwise repeating S42 and S43 until the individual position in the new problem solution matrix is smaller than;
Finding the value of the abscissa of the team leader position corresponding to the position in the problem solution matrix, noted asThe saidI.e. the number of parallel threads, the code segments to be processed in the code segment matrix to be processedThe number of parallel threads runs, and the iterative use of the code fragments is realized at the moment.
According to the invention, the code segment to be processed is obtained by combining the first code extraction iteration condition and the second code extraction iteration condition, the code segment extraction is completed, the parallel line number of the code segment to be processed is adjusted based on a differential creative search algorithm, the team leader position is obtained through continuous learning and convergence of individuals, the parallel line number is obtained, and the code segment iteration is completed.
The embodiment also discloses a system of the code segment extraction iteration using method based on parallelization, which specifically comprises a code segment hot spot function acquisition module, a code segment running quality measurement module, a similarity code segment detection module and a parallel thread number adjustment module;
The code fragment hotspot function acquisition module is used for classifying the code fragment function calling time duty ratio matrix to obtain a code fragment hotspot function;
The code segment running quality measuring module is used for measuring the running quality of the code segment by using the time complexity of the objective function in the code segment and the running time of the code segment in the program;
the similarity code segment detection module is used for carrying out similarity detection on the code segment generation character strings and deleting code segments with similar characteristics;
the parallel thread number adjusting module is used for adjusting the parallel thread number by using a differential creative search algorithm to realize the optimization of the code segment running efficiency.
The invention has the following beneficial effects:
1. According to the method, the code fragment function is obtained, the calling time proportion of the code fragment function is calculated, the K neighbor method is used for classifying the code fragment function calling time proportion set to obtain the code fragment hot spot function, and the code fragment hot spot function is recorded as a first code extraction iteration condition.
2. According to the method, the running quality of the code segments is measured by using the time complexity of the objective function in the code segments and the running time of the code segments in the program, the time complexity of the objective function is obtained through the objective function calling relation, and the running time of the code segments in the program is optimized by using the black-fin iris optimization algorithm to obtain the optimal running time.
3. The method comprises the steps of converting character strings in code segments into character string feature vectors, obtaining similarity code segments by calculating the similarity of the character string feature vectors, recording the similarity code segments as second code extraction iteration conditions, obtaining code segments to be processed by combining the first code extraction iteration conditions and the second code extraction iteration conditions, adjusting the parallel threads of the code segments to be processed based on a differential creative search algorithm, achieving the highest running efficiency of the code segments to be processed, obtaining the parallel threads, and completing code segment iteration.
Of course, it is not necessary for any one product to practice the invention to achieve all of the advantages set forth above at the same time.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the description of the present invention, it should be understood that the terms "open," "upper," "lower," "top," "middle," "inner," and the like indicate an orientation or positional relationship, merely for convenience of description and to simplify the description, and do not indicate or imply that the components or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus should not be construed as limiting the invention.
The implementation discloses a code segment extraction iteration using method based on parallelization, which specifically comprises the following steps:
s1, acquiring a code fragment function, generating a code fragment function calling time duty ratio matrix, classifying the code fragment function calling time duty ratio matrix by using a K neighbor method to obtain a code fragment hot spot function, and marking the code fragment hot spot function as a first code extraction iteration condition;
the step S1 comprises the following steps:
S11, acquiring a code fragment function, calculating the calling time duty ratio of the code fragment function to obtain a code fragment function calling time duty ratio set, and recording asWhereinRepresent the firstSetting the feature dimension of the code segment function calling time ratio in the code segment function calling time ratio set as the code segment function calling time ratioGenerating code fragment function call time duty ratio matrixAs will be described below,
,
Wherein,Representing the code fragment function call time in the duty cycle matrixThe dimension of each feature isThe code fragment function call time duty cycle of (a);
Setting a comparison code fragment function set, calculating the calling time duty ratio of the comparison code fragment function in the comparison code fragment function set in the comparison code fragment to obtain a comparison code fragment function time duty ratio set, selecting a list of the code fragment function calling time duty ratio set marked as a first code fragment function calling time duty ratio set from the code fragment function calling time duty ratio matrixWhereinRepresenting the code fragment function call time in the duty cycle matrixThe dimension of each feature isThe code fragment function call time duty cycle of (a);
s12, setting a similarity threshold asSelecting the comparison code segment function time duty ratio set to be larger thanAccording to the similarity of the sample data of the first code fragment function calling time duty ratio set and the second code fragment function calling time duty ratio set, marking the code fragment function calling time duty ratio corresponding to the minimum similarity as a nearby point to obtain a nearby point setWhereinRepresent the firstA plurality of adjacent points;
Setting upRepresentative coefficients representing neighboring points in the set of neighboring points,Representative coefficients representing the code fragment function call time duty cycles in the first set of code fragment function call time duty cycles,The weight is represented by a weight that,Representing classification function and taking 1 when the data sample corresponding to the minimum similarity value is in the first code fragment function calling time duty ratio set, otherwise taking 0, calculating the weight of the adjacent point in the adjacent point setThe calculation formula is as follows,
Wherein,Weights representing the neighboring points in the set of neighboring points,Representing the first of a set of nearby pointsThe representative coefficients of the individual neighboring points are,;
Calculating to obtain a weight value of a nearby point in a nearby point set, selecting a maximum value of the weight value of the nearby point in the nearby point set, obtaining sample data of a first code fragment function call time duty cycle set of the nearby point corresponding to the maximum value of the weight value of the nearby point in the nearby point set, recording the sample data as a code fragment function call time duty cycle to be classified, forming a code fragment function call time duty cycle set by the code fragment function call time duty cycle to be classified, finding a code fragment function corresponding to the code fragment function call time duty cycle in the code fragment function call time duty cycle set, recording the code fragment hotspot function as a code fragment hotspot function, and recording the code fragment hotspot function as a first code extraction iteration condition;
s2, measuring the running quality of the code segments by using the time complexity of the objective function in the code segments and the running time of the code segments in the program, and optimizing the running time of the code segments in the program by using a black-fin iris optimization algorithm to obtain optimized code segments;
the step S2 comprises the following steps:
S21, the set code segment comprisesObtaining an objective function set asWhereinRepresent the firstSelecting an objective function in the objective function setAs an initial function, generating a directed graph according to the calling relation of the initial functionInto contiguous linked lists, whereRepresenting a call relationship set;
the calling relation set for setting the initial function comprisesObtaining an atomic function set asWhereinRepresent the firstThe time complexity calculation process of the atomic functions in the atomic function set is as follows:
s211, setting the loop body set asWhereinRepresent the firstThe number of the cyclic variables is a function of,
When the number of times of changing the circulation variable in the circulation body set is any constant, the time complexity of the circulation variable in the circulation body set isWhen the number of the circulation variable changes in the circulation body set is recorded as an indefinite itemAt this time, the time complexity of the cyclic variables in the cyclic volume set isWhen the number of the circulation variable changes in the circulation body set is recorded as an indefinite itemAnd the change of the circulation variable in the circulation body set is enlarged by 2 times, at the moment, the time complexity of the circulation variable in the circulation body set isCompleting judgment of the circulation variables in the circulation body set;
S212, setting the loop body nesting set asWhereinRepresent the firstA loop body nested relationship when loop variables in the loop body setAndSatisfying the cyclic body nesting relationship in the cyclic body nesting set, and circulating variables in the cyclic body setIs an outer layer circulation, whereinAndRespectively represent the firstAndThe time complexity of the cyclic variables in the cyclic volume set isSetting a basic sentence cyclic body execution sentence set, selecting the maximum frequency execution sentence in the basic sentence cyclic body execution sentence set, wherein the maximum frequency execution sentence time complexity in the basic sentence cyclic body execution sentence setThe atomic functions in the atomic function set compriseExecuting statement set by a basic statement loop body to obtain the statement setThe maximum frequency execution statement in the set of execution statements of the basic statement loop body, the time complexity of the atomic function in the set of atomic functions;
S22, after obtaining the time complexity of the atomic function in the atomic function set, performing backtracking operation on the atomic function in the atomic function set according to S211 and S212 to obtain the time complexity of the initial function, calculating to obtain the time complexity of the objective function in the code segment, generating the time complexity set of the objective function in the code segment, and setting the time complexity threshold as followsDiscarding the code segment having an objective function time complexity set greater thanObtaining a processed code segment;
s23, setting the target function set of the processed code segment asWhereinRepresent the firstObjective function, the characteristic dimension of the objective function is as followsGenerating an objective function matrix of a code segmentAs will be described below,
,
Wherein,Represent the firstThe dimension of each feature isIs a target function of (2);
optimizing code segment running time in program by using black-wing iris optimization algorithm, and setting fitness functionWhereinIndicating the interrupt time of the interrupt service,The execution time of the code segment is indicated,The error time is represented by the following specific procedures:
S231, setting the target function in the target function matrix of the code segment to represent the position of the iris nigricans, wherein the population individuals of the iris nigricans areThe characteristic dimension of the iris nigrum isFirst, theDimension of only featuresThe initial position calculation formula of the iris nigrum is as follows,
Wherein,Represent the firstDimension of only featuresIs used for the initial position of the iris nigrum,Represent the firstIris Tectoria with black wings at the first stageThe upper bound of the dimension is maintained,Represent the firstIris Tectoria with black wings at the first stageThe dimension of the lower bound is maintained,Representing a random number and;
S232, continuously changing the position of the iris nigricans during the process of attacking hunting objects, continuously optimizing the running time of the code fragments in the program, and setting the iris nigricans in the programThe position at the time of iteration isIris nigromaculata (Tex. Nigromaculata) inThe position at the time of iteration isThe maximum iteration number isThe judgment coefficient of the iris nigricans attack hunting object is,Representing a random number and,The calculation formula is as follows,
,
,
When the iris is atAt location, optimizing the run-time of the code segment in the program completes the firstIterating for the second time;
S233, introducing a iris nigricans leader in the migration process, and setting population fitness of the iris nigricans asWhen the current fitness isGreater thanWhen the population of the iris nigricans is migrated, the population of the iris nigricans is led by a leader of the iris nigricans, and the migration process is setThe position at the time of iteration isDuring migrationThe position at the time of iteration isThe migration process coefficient of the iris nigricans isThe cauchy distribution function isThe position of the iris nigromaculata leader isRepresenting the running time of the code segment in the program, the calculation formula is as follows,
,
,
Continuously searching the minimum fitness of the iris nigrum in the migration process, setting the current iteration times, stopping iteration when the current iteration times are larger than the maximum iteration times, and completing the optimization of the running time of the code segment in the program to obtain the optimized code segment;
S3, generating a character string matrix from the optimized code segments, detecting the similarity of character strings in the character string matrix, removing the code segments with similar characteristics to obtain similarity code segments, and marking the similarity code segments as second code extraction iteration conditions;
The step S3 comprises the following steps:
s31, setting the optimized code segment to containA character string, noted asWhereinRepresent the firstCharacter strings, the characteristic dimension of the character strings is as followsObtaining character string matrixAs will be described below,
,
Wherein,Represent the firstThe dimension of each feature isIs a character string of (a);
Converting the character strings in the character string matrix into character string feature vectors, taking 2 character string feature vectors in the character string matrix, and normalizing the 2 character string feature vectors in the character string matrix to obtain normalized vectorsAndThe similarity calculation formula is as follows,
Wherein,Representing the similarity of character strings in the character string matrix;
s32, calculating vector cosine values of 2 character string feature vectors in the character string matrix, and setting a similarity threshold asThe vector cosine value threshold isWhen the vector cosine value of the 2 character string feature vectors in the character string matrix is greater than or equal toAnd the similarity of the character strings in the character string matrix is greater than or equal toWhen the character strings in the character string matrix are the same, deleting the character strings in the same character string matrix, and when the vector cosine value of the feature vectors of 2 character strings in the character string matrix is smaller thanAnd the similarity of the character strings in the character string matrix is smaller thanWhen the character strings in the character string matrix are different, the character strings in the character string matrix are reserved, a similarity code segment is obtained, and the similarity code segment is marked as a second code extraction iteration condition;
S4, combining the first code extraction iteration condition and the second code extraction iteration condition to obtain a code segment to be processed, operating the code segment to be processed, adjusting the parallel threads, optimizing the code segment operation efficiency based on a differential creative search algorithm, and realizing code segment extraction iteration;
The step S4 comprises the following steps:
S41, a first code extraction iteration condition is a code segment hot spot function, a second code extraction iteration condition is a similarity code segment, the code segment hot spot function is added into the similarity code segment, code segment extraction is completed, a code segment set to be processed is obtained, and the code segment set is recorded asWhereinRepresent the firstSetting the feature dimension of the code segment to be processed asGenerating a code segment matrix to be processedAs will be described below,
,
Wherein,Represent the firstThe dimension of each feature isTo be processed;
Optimizing the parallel threads by using a differential creative search algorithm, realizing optimization of the running efficiency of the code segments to be processed in the code segment matrix to be processed, and setting the code segment matrix to be processedRepresenting the number of problem solutions asProblem solution dimension isThe code segment matrix to be processed is recorded as a problem solution matrix, wherein an individual generation formula in the problem solution matrix is as follows,
Wherein,Representing a random number and,Representing problem solution matrixThe upper bound of the dimension is maintained,Representing problem solution matrixMaintaining a lower bound;
S42, setting fitness functionWhereinIndicating the efficiency of the storage and,The input efficiency is indicated as such,Representing output efficiency, calculating the fitness of the individuals in the problem solution matrix, ranking according to the fitness of the individuals in the problem solution matrix from big to small to obtain ranking numbers, setting the first stage in the differential knowledge acquisition stageThe secondary iteration differential knowledge acquisition rate isFirst, theThe secondary iteration differential knowledge acquisition variable isFirst, theIndividual rank number of the next iterationThe maximum iteration number isThe calculation formula is as follows,
,
,
Setting a first threshold value asWhen the firstThe secondary iteration differential knowledge acquisition variable is smaller thanWhen the individual in the problem solution matrix is selected as the test individual, the test individual is according to the firstLearning, absorbing and integrating new knowledge or experience by iterative differential knowledge acquisition rate, starting to optimize parallel thread number process, setting the firstThe individual positions of the iterative tests are as followsFirst, theIndividual locations in the sub-iteration problem solution matrix areThen (1)The individual position calculation formula in the sub-iteration problem solution matrix is as follows,
After the individual positions in the problem solution matrix are replaced, a new problem solution matrix is obtained, and the process of optimizing the number of parallel threads is completedIterating for the second time;
S43, introducing a team leader in a convergence thinking stage, wherein the position of the team leader meets the maximum fitness function, and the running efficiency of the code segments to be processed in the code segment matrix to be processed is the best at the momentThe position of the secondary iteration team leader isSelecting individual positions in a new problem solution matrixAndFirst, theThe secondary iteration coefficients are respectively、AndThe individual location update calculation formula in the new problem solution matrix is as follows,
,
,
Coefficients ofContinuously adjusting the position of the team leader, and setting the current iteration number and a second threshold valueWhen the current iteration number is equal to the maximum iteration number and the individual position in the new problem solution matrix is smaller thanAnd otherwise repeating S42 and S43 until the current iteration number is equal to the maximum iteration number and the individual position in the new problem solution matrix is smaller than;
Finding the value of the abscissa of the team leader position corresponding to the position in the problem solution matrix, noted asThe saidI.e. the number of parallel threads, the code segments to be processed in the code segment matrix to be processedThe number of parallel threads runs, and the iterative use of the code fragments is realized at the moment.
The embodiment also discloses a system of the code segment extraction iteration using method based on parallelization, which specifically comprises a code segment hot spot function acquisition module, a code segment running quality measurement module, a similarity code segment detection module and a parallel thread number adjustment module;
The code fragment hotspot function acquisition module is used for classifying the code fragment function calling time duty ratio matrix to obtain a code fragment hotspot function;
The code segment running quality measuring module is used for measuring the running quality of the code segment by using the time complexity of the objective function in the code segment and the running time of the code segment in the program;
the similarity code segment detection module is used for carrying out similarity detection on the code segment generation character strings and deleting code segments with similar characteristics;
the parallel thread number adjusting module is used for adjusting the parallel thread number by using a differential creative search algorithm to realize the optimization of the code segment running efficiency.
In the description of the present specification, the descriptions of the terms "one embodiment," "example," "specific example," and the like, mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
The above disclosed preferred embodiments of the invention are merely intended to help illustrate the invention. The preferred embodiments are not exhaustive or to limit the invention to the precise form disclosed. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the invention and the practical application, to thereby enable others skilled in the art to best understand and utilize the invention.