Movatterモバイル変換


[0]ホーム

URL:


CN119201131A - A method and system for iterative use of code snippet extraction based on parallelization - Google Patents

A method and system for iterative use of code snippet extraction based on parallelization
Download PDF

Info

Publication number
CN119201131A
CN119201131ACN202411586489.5ACN202411586489ACN119201131ACN 119201131 ACN119201131 ACN 119201131ACN 202411586489 ACN202411586489 ACN 202411586489ACN 119201131 ACN119201131 ACN 119201131A
Authority
CN
China
Prior art keywords
code
function
matrix
iteration
code snippet
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411586489.5A
Other languages
Chinese (zh)
Inventor
季克勤
何明锋
程颖
吴峰
贺燕
马蕾
丁珊
叶宏
瞿迪庆
徐敏
张帅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jinhua Bada Group Co ltd
State Grid Zhejiang Electric Power Co Ltd
Jinhua Power Supply Co of State Grid Zhejiang Electric Power Co Ltd
Original Assignee
Jinhua Bada Group Co ltd
State Grid Zhejiang Electric Power Co Ltd
Jinhua Power Supply Co of State Grid Zhejiang Electric Power Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jinhua Bada Group Co ltd, State Grid Zhejiang Electric Power Co Ltd, Jinhua Power Supply Co of State Grid Zhejiang Electric Power Co LtdfiledCriticalJinhua Bada Group Co ltd
Priority to CN202411586489.5ApriorityCriticalpatent/CN119201131A/en
Publication of CN119201131ApublicationCriticalpatent/CN119201131A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

The invention relates to the technical field of electronic digital data processing, and discloses a code segment extraction iteration using method and system based on parallelization. The method comprises the steps of obtaining a code fragment function, obtaining the code fragment hotspot function by using a K neighbor method, recording the code fragment hotspot function as a first code extraction iteration condition, calculating the time complexity of an objective function in the code fragment to obtain a processed code fragment, optimizing the running time of the processed code fragment in a program by using a black-wing iris optimization algorithm to obtain an optimized code fragment, carrying out similarity detection on the optimized code fragment, screening to obtain a similarity code fragment, recording the similarity code fragment as a second code extraction iteration condition, finally combining the first code extraction iteration condition and the second code extraction iteration condition to obtain a code fragment to be processed, optimizing the parallel thread number of the code fragment to be processed, and realizing code fragment extraction iteration.

Description

Code segment extraction iteration using method and system based on parallelization
Technical Field
The invention relates to the technical field of electronic digital data processing, in particular to a code segment extraction iteration using method and system based on parallelization.
Background
The Chinese patent CN102279750B discloses an iterative code generation method based on domain knowledge sharing, which specifically comprises the steps of firstly developing a core generation system based on dynamic language, wherein the core generation system comprises a use interface, a development interface, an explanation file and an automatic test and deployment suite, generating a conventional application system by using the core code generation system, wherein the conventional application system comprises a common knowledge code and domain data which are extracted so as to facilitate iteration, developing a specific domain application system based on the common knowledge code and the domain data, and extracting the common knowledge code by using the specific domain application system. The method only realizes the extraction iteration of codes, has low code extraction speed, and does not pay attention to the operation efficiency and time complexity of extracting the code fragments.
When the same program code runs on different architectures, good time complexity cannot be obtained, the code segments are subjected to iterative compiling optimization through experience in the traditional method, the optimal code segment running time cannot be obtained in the iterative compiling optimization process, portability of the code segments is difficult, the extraction iteration difficulty is high, the code segments are required to be rewritten each time in the traditional method, and the parallel thread number of the code segments is difficult to determine after the copying is finished.
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 respectivelyAndThe 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.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the invention, the drawings that are needed for the description of the embodiments will be briefly introduced below, it being obvious that the drawings in the following description are only some embodiments of the invention, and that it is also possible for a person skilled in the art to obtain the drawings from these drawings without inventive effort.
FIG. 1 is a schematic diagram of a system for parallelizing code segment extraction iteration using method of the present invention.
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 respectivelyAndThe 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.

Claims (9)

Translated fromChinese
1.一种基于并行化的代码片段提取迭代使用方法,其特征在于,包括如下步骤:1. A method for iterative use of code snippets extracted based on parallelization, characterized in that it comprises the following steps:S1、获取代码片段函数,生成代码片段函数调用时间占比矩阵,使用K近邻法对所述代码片段函数调用时间占比矩阵进行分类,得到代码片段热点函数,将代码片段热点函数记为第一代码提取迭代条件;S1. Obtain a code snippet function, generate a code snippet function call time proportion matrix, classify the code snippet function call time proportion matrix using a K-nearest neighbor method, obtain a code snippet hotspot function, and record the code snippet hotspot function as the first code extraction iteration condition;S2、使用代码片段中目标函数时间复杂度和代码片段在程序中的运行时间衡量代码片段的运行质量,并优化代码片段在程序中的运行时间,得到优化后的代码片段;S2. Use the time complexity of the target function in the code snippet and the running time of the code snippet in the program to measure the running quality of the code snippet, and optimize the running time of the code snippet in the program to obtain an optimized code snippet;S3、根据所述优化后的代码片段生成字符串矩阵,对字符串矩阵中字符串进行相似度检测,去除特征相似的代码片段,得到相似度代码片段,将所述相似度代码片段记为第二代码提取迭代条件;S3, generating a string matrix according to the optimized code snippets, performing similarity detection on the strings in the string matrix, removing code snippets with similar features, obtaining similar code snippets, and recording the similar code snippets as the second code extraction iteration condition;S4、结合所述第一代码提取迭代条件和第二代码提取迭代条件,得到待处理的代码片段,运行待处理的代码片段,并调整并行线程数,优化代码片段运行效率,实现代码片段提取迭代。S4. Combining the first code extraction iteration condition and the second code extraction iteration condition, obtain the code snippet to be processed, run the code snippet to be processed, and adjust the number of parallel threads to optimize the code snippet running efficiency and realize code snippet extraction iteration.2.根据权利要求1所述的一种基于并行化的代码片段提取迭代使用方法,其特征在于,所述S1包括如下步骤:2. The method for iteratively using code snippets extracted based on parallelization according to claim 1, characterized in that said S1 comprises the following steps:S11、获取代码片段函数,生成代码片段函数调用时间占比矩阵,使用K近邻法对所述代码片段函数调用时间占比矩阵进行分类,得到临近点集合;S11, obtaining a code snippet function, generating a code snippet function call time proportion matrix, and classifying the code snippet function call time proportion matrix using a K-nearest neighbor method to obtain a set of adjacent points;S12、选取临近点集合中临近点的权重值最大值,记为代码片段热点函数,将所述代码片段热点函数记为第一代码提取迭代条件。S12. Select the maximum weight value of the adjacent points in the adjacent point set, record it as the code snippet hotspot function, and record the code snippet hotspot function as the first code extraction iteration condition.3.根据权利要求2所述的一种基于并行化的代码片段提取迭代使用方法,其特征在于,所述S2包括如下步骤:3. The method for iteratively using code snippets extracted based on parallelization according to claim 2, characterized in that said S2 comprises the following steps:S21、设定代码片段中包含目标函数,得到目标函数集合,选定所述目标函数集合中目标函数作为初始函数,所述初始函数的调用关系集合中包含原子函数,得到原子函数集合;S21, setting the code fragment to include a target function to obtain a target function set, selecting a target function in the target function set as an initial function, wherein the call relationship set of the initial function includes an atomic function to obtain an atomic function set;S22、计算原子函数集合中的原子函数的时间复杂度,再将原子函数集合中的原子函数进行回溯操作,得到处理后的代码片段;S22, calculating the time complexity of the atomic functions in the atomic function set, and then backtracking the atomic functions in the atomic function set to obtain processed code fragments;S23、使用黑翅鸢优化算法优化处理后的代码片段在程序中的运行时间,得到优化后的代码片段。S23. Use the Black Kite optimization algorithm to optimize the running time of the processed code snippet in the program to obtain an optimized code snippet.4.根据权利要求2所述的一种基于并行化的代码片段提取迭代使用方法,其特征在于,所述S21包括如下步骤:4. The method for iteratively using code snippets extracted based on parallelization according to claim 2, characterized in that said S21 comprises the following steps:S211、设定循环体集合,对循环体集合中的循环变量进行判断,得到循环体集合中的循环变量的时间复杂度;S211, setting a loop body set, judging loop variables in the loop body set, and obtaining the time complexity of the loop variables in the loop body set;S212、所述循环体集合中的循环变量的时间复杂度根据循环体嵌套关系和基本语句循环体执行语句处理后,得到原子函数集合中的原子函数的时间复杂度。S212. The time complexity of the loop variables in the loop body set is obtained after the time complexity of the atomic functions in the atomic function set is processed according to the loop body nesting relationship and the basic statement loop body execution statement.5.根据权利要求2所述的一种基于并行化的代码片段提取迭代使用方法,其特征在于,所述S23包括如下步骤:5. The method for iteratively using code snippets extracted based on parallelization according to claim 2, characterized in that said S23 comprises the following steps:S231、设定适应度函数,其中表示中断服务中断时间,表示代码片段执行时间,表示误差时间;设定黑翅鸢种群个体数为,黑翅鸢特征维度为,第只、特征维度的黑翅鸢初始位置计算公式如下,S231. Setting fitness function ,in Indicates the interruption time of the service. Indicates the execution time of the code snippet, represents the error time; the number of individuals in the black-winged kite population is set to , the characteristic dimension of black kite is , Only feature dimension The calculation formula for the initial position of the black-winged kite is as follows: ,其中,表示第只、特征维度的黑翅鸢初始位置,表示第只黑翅鸢在第维上界,表示第只黑翅鸢在第维下界,表示随机数且in, Indicates Only feature dimension The initial position of the black-winged kite, Indicates A black kite Dimensional upper bound, Indicates A black kite Dimensional lower bound, represents a random number and ;S232、黑翅鸢攻击猎物过程中,黑翅鸢不断改变自身位置,不断优化代码片段在程序中的运行时间,设定黑翅鸢在次迭代时位置为,黑翅鸢在次迭代时位置为,最大迭代次数为,黑翅鸢攻击猎物判断系数为表示随机数且表示为常数,计算公式如下,S232, Black-winged kite attacks prey, Black-winged kite constantly changes its position, constantly optimizes the running time of the code snippet in the program, and sets the Black-winged kite The position at the iteration is , Black-winged Kite The position at the iteration is , the maximum number of iterations is , the judgment coefficient of black-winged kite attacking prey is , represents a random number and , , Expressed as a constant, the calculation formula is as follows, , ,当黑翅鸢在处位置时,优化代码片段在程序中的运行时间完成第次迭代;When the black kite When the code snippet is in the same location, the running time of the optimized code snippet in the program is completed. Iterations;S233、黑翅鸢在迁徙过程中,引入黑翅鸢领导者,设定黑翅鸢种群适应度为,当当前适应度大于时,黑翅鸢领导者领导黑翅鸢种群进行迁徙;设定迁徙过程中次迭代时位置为,迁徙过程中次迭代时位置为,黑翅鸢迁徙过程系数为,柯西分布函数为,黑翅鸢领导者位置为,表示代码片段在程序中的运行时间,计算公式如下,S233, Black-winged kites introduce black-winged kite leaders during migration, and set the fitness of the black-winged kite population to , when the current fitness Greater than When the black-winged kite leader leads the black-winged kite population to migrate; set the migration process The position at the iteration is , during migration The position at the iteration is , the black kite migration process coefficient is , the Cauchy distribution function is , the leader position of the Black Winged Kite is , represents the running time of the code snippet in the program, and the calculation formula is as follows, , ,黑翅鸢在迁徙过程中不断寻找最小适应度,设定当前迭代次数,当当前迭代次数大于最大迭代次数时,停止迭代,完成对代码片段在程序中的运行时间优化,得到优化后的代码片段。The black-winged kite continuously searches for the minimum fitness during migration and sets the current number of iterations. When the current number of iterations is greater than the maximum number of iterations, the iteration is stopped, and the running time of the code snippet in the program is optimized to obtain the optimized code snippet.6.根据权利要求3所述的一种基于并行化的代码片段提取迭代使用方法,其特征在于,所述S3包括如下步骤:6. The method for iteratively using code snippets extracted based on parallelization according to claim 3, characterized in that said S3 comprises the following steps:S31、根据所述优化后的代码片段生成得到字符串矩阵,将所述字符串矩阵中的字符串转化为字符串特征向量,计算字符串矩阵中字符串的相似度和字符串特征向量的向量余弦值,筛选字符串矩阵中字符串,得到相似度代码片段,将所述相似度代码片段记为第二代码提取迭代条件。S31. Generate a string matrix according to the optimized code snippet, convert the strings in the string matrix into string feature vectors, calculate the similarity of the strings in the string matrix and the vector cosine value of the string feature vector, filter the strings in the string matrix, obtain similarity code snippets, and record the similarity code snippets as the second code extraction iteration condition.7.根据权利要求4所述的一种基于并行化的代码片段提取迭代使用方法,其特征在于,所述S4包括如下步骤:7. The method for iteratively using code snippets extracted based on parallelization according to claim 4, characterized in that said S4 comprises the following steps:S41、结合所述第一代码提取迭代条件和第二代码提取迭代条件,得到待处理的代码片段,生成待处理的代码片段矩阵;S41. Combining the first code extraction iteration condition and the second code extraction iteration condition, obtaining code fragments to be processed, and generating a code fragment matrix to be processed;使用差异化创意搜索算法优化并行线程数,实现优化待处理的代码片段矩阵中的待处理的代码片段运行效率,设定待处理的代码片段矩阵中表示问题解决方案数量为,问题解决方案维度为,将待处理的代码片段矩阵记为问题解决方案矩阵,所述问题解决方案矩阵中个体生成公式如下,Use the differentiated creative search algorithm to optimize the number of parallel threads, optimize the running efficiency of the code snippets to be processed in the code snippet matrix to be processed, and set the code snippets to be processed in the code snippet matrix The number of solutions to the problem is , the problem solution dimension is , the code snippet matrix to be processed is recorded as the problem solution matrix, and the individual generation formula in the problem solution matrix is as follows, ,其中,表示随机数且表示问题解决方案矩阵第维上界,表示问题解决方案矩阵第维下界;in, represents a random number and , Represents the problem solution matrix Dimensional upper bound, Represents the problem solution matrix Dimensional lower bound;S42、设定适应度函数,其中表示存储效率,表示输入效率,表示输出效率;计算所述问题解决方案矩阵中个体的适应度,根据问题解决方案矩阵中个体的适应度从大到小进行排名,获得排名序号;在差异化知识获取阶段,设定第次迭代差异化知识获取率为,第次迭代差异化知识获取变量为,第次迭代个体排名序号为,最大迭代次数为,计算公式如下,S42. Setting fitness function ,in Represents storage efficiency, represents the input efficiency, represents the output efficiency; calculate the fitness of individuals in the problem solution matrix, rank them from large to small according to their fitness in the problem solution matrix, and obtain the ranking number; in the differentiated knowledge acquisition stage, set the first The differential knowledge acquisition rate of the iteration is , The variable of differential knowledge acquisition in the iteration is , The individual ranking number of the iteration is , the maximum number of iterations is , the calculation formula is as follows, , ,设定第一阈值为,当第次迭代差异化知识获取变量小于时,选取问题解决方案矩阵中个体作为试验个体,所述试验个体按照第次迭代差异化知识获取率学习、吸收和整合新的知识或经验,开始优化并行线程数过程;设定第次迭代试验个体位置为,第次迭代问题解决方案矩阵中个体位置为,则第次迭代问题解决方案矩阵中个体位置计算公式如下,Set the first threshold to , when The number of iterations of differential knowledge acquisition variables is less than When the problem solution matrix is selected, the individuals are selected as experimental individuals. The first iteration differentiates the knowledge acquisition rate to learn, absorb and integrate new knowledge or experience, and start the process of optimizing the number of parallel threads; set the The individual position of the iteration test is , The individual position in the solution matrix of the iteration problem is , then The formula for calculating the individual position in the solution matrix of the iteration problem 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 completed. Iterations;S43、在收敛思维阶段,引入团队领导者,所述团队领导者位置满足适应度函数最大,此时待处理的代码片段矩阵中的待处理的代码片段运行效率最佳;设定第次迭代团队领导者的位置为,选取新的问题解决方案矩阵中个体位置分别为,第次迭代系数分别为,最大迭代次数为,则新的问题解决方案矩阵中个体位置更新计算公式如下,S43. In the convergent thinking stage, a team leader is introduced. The team leader position satisfies the maximum fitness function. At this time, the code fragments to be processed in the code fragment matrix to be processed have the best running efficiency. Set the The position of the iteration team leader is , select the individual positions in the new problem solution matrix respectively and , The iteration coefficients are , and , the maximum number of iterations is , then the calculation formula for individual position update in the new problem solution matrix is as follows: , ,系数不断调节所述团队领导者位置,设定当前迭代次数和第二阈值,当当前迭代次数等于最大迭代次数且新的问题解决方案矩阵中个体位置小于时,得到团队领导者位置;否则重复S42和S43直至当前迭代次数等于最大迭代次数时,且新的问题解决方案矩阵中个体位置小于coefficient Continuously adjust the team leader position, set the current iteration number and the second threshold , when the current number of iterations is equal to the maximum number of iterations and the position of the individual in the new problem solution matrix is less than , the team leader position is obtained; otherwise, S42 and S43 are repeated until the current number of iterations is equal to the maximum number of iterations, and the individual position in the new problem solution matrix is less than .8.根据权利要求4所述的一种基于并行化的代码片段提取迭代使用方法,其特征在于,8. The method for iteratively using code snippets extracted based on parallelization according to claim 4, characterized in that:找到团队领导者位置在问题解决方案矩阵中对应位置的横坐标的值,记为,所述即为并行线程数,待处理的代码片段矩阵中的待处理的代码片段以个并行线程数运行,此时实现代码片段迭代使用。Find the value of the horizontal coordinate of the position of the team leader in the problem solution matrix, recorded as , is the number of parallel threads. The code fragments to be processed in the code fragment matrix are The number of parallel threads running is 1, and the code snippet is iteratively used.9.一种实现如权利要求1-8任意一项所述基于并行化的代码片段提取迭代使用方法的系统,其特征在于,具体包括:代码片段热点函数获取模块、代码片段运行质量衡量模块、相似度代码片段检测模块和并行线程数调整模块;9. A system for implementing the method for iterative use of code snippets extracted based on parallelization as claimed in any one of claims 1 to 8, characterized in that it specifically comprises: a code snippet hot function acquisition module, a code snippet operation quality measurement module, a similarity code snippet detection module and a parallel thread number adjustment module;所述代码片段热点函数获取模块用于代码片段函数调用时间占比矩阵进行分类得到代码片段热点函数;The code snippet hot function acquisition module is used to classify the code snippet function call time proportion matrix to obtain the code snippet hot function;所述代码片段运行质量衡量模块用于使用代码片段中目标函数时间复杂度和代码片段在程序中的运行时间衡量代码片段运行质量;The code snippet execution quality measurement module is used to measure the code snippet execution quality using the time complexity of the target function in the code snippet and the execution time of the code snippet in the program;所述相似度代码片段检测模块用于对代码片段生成字符串进行相似度检测并删去特征相似的代码片段;The similarity code snippet detection module is used to perform similarity detection on the character strings generated by the code snippets and delete the code snippets with similar features;所述并行线程数调整模块用于使用差异化创意搜索算法调整并行线程数实现优化代码片段运行效率。The parallel thread number adjustment module is used to use a differentiated creative search algorithm to adjust the number of parallel threads to optimize the running efficiency of the code snippet.
CN202411586489.5A2024-11-082024-11-08 A method and system for iterative use of code snippet extraction based on parallelizationPendingCN119201131A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202411586489.5ACN119201131A (en)2024-11-082024-11-08 A method and system for iterative use of code snippet extraction based on parallelization

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202411586489.5ACN119201131A (en)2024-11-082024-11-08 A method and system for iterative use of code snippet extraction based on parallelization

Publications (1)

Publication NumberPublication Date
CN119201131Atrue CN119201131A (en)2024-12-27

Family

ID=94076327

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202411586489.5APendingCN119201131A (en)2024-11-082024-11-08 A method and system for iterative use of code snippet extraction based on parallelization

Country Status (1)

CountryLink
CN (1)CN119201131A (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN101694628A (en)*2009-10-212010-04-14中国人民解放军国防科学技术大学Parallel computer system performance simulation method by combining serial simulation and parallel simulation
CN102279750A (en)*2011-08-302011-12-14浙江大学Iterative code generation method based on domain knowledge sharing
WO2014200501A1 (en)*2013-06-142014-12-18Intel CorporationCompiler optimization for complex exponential calculations
KR20220077894A (en)*2020-12-022022-06-09한양대학교 에리카산학협력단Device and method for predicting stripped binary function symbols
CN116303844A (en)*2022-12-252023-06-23航天信息股份有限公司Method and system for identifying administrative division codes of affiliated areas based on NLP and statistics
CN117951251A (en)*2024-01-152024-04-30东北大学Efficient code searching method based on product quantization
CN117992572A (en)*2024-02-022024-05-07东北大学Code searching system and method based on pre-training model
CN118295640A (en)*2024-04-112024-07-05河南旭方科技有限公司Software development management method based on artificial intelligence
CN118502964A (en)*2024-07-122024-08-16安徽大学 CUDA simulation method for the neoclassical annular viscosity torque of Tokamak
CN118709181A (en)*2024-04-162024-09-27四川大学 A method for identifying malicious code authors and detecting code infringement based on multi-feature fusion

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN101694628A (en)*2009-10-212010-04-14中国人民解放军国防科学技术大学Parallel computer system performance simulation method by combining serial simulation and parallel simulation
CN102279750A (en)*2011-08-302011-12-14浙江大学Iterative code generation method based on domain knowledge sharing
WO2014200501A1 (en)*2013-06-142014-12-18Intel CorporationCompiler optimization for complex exponential calculations
KR20220077894A (en)*2020-12-022022-06-09한양대학교 에리카산학협력단Device and method for predicting stripped binary function symbols
CN116303844A (en)*2022-12-252023-06-23航天信息股份有限公司Method and system for identifying administrative division codes of affiliated areas based on NLP and statistics
CN117951251A (en)*2024-01-152024-04-30东北大学Efficient code searching method based on product quantization
CN117992572A (en)*2024-02-022024-05-07东北大学Code searching system and method based on pre-training model
CN118295640A (en)*2024-04-112024-07-05河南旭方科技有限公司Software development management method based on artificial intelligence
CN118709181A (en)*2024-04-162024-09-27四川大学 A method for identifying malicious code authors and detecting code infringement based on multi-feature fusion
CN118502964A (en)*2024-07-122024-08-16安徽大学 CUDA simulation method for the neoclassical annular viscosity torque of Tokamak

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
LEHR, J.-P等: "Tool-Supported Mini-App Extraction to Facilitate Program Analysis and Parallelization", ICPP 2021: 50TH INTERNATIONAL CONFERENCE ON PARALLEL PROCESSING, 1 November 2022 (2022-11-01)*
孟慧玲: "数据挖掘算法在GPU平台上的并行化实现", 中国硕士学位论文全文数据库, 15 January 2023 (2023-01-15)*
张其良;张昱;周坤;: "CCodeExtractor:一种针对C程序自动化的函数提取方法", 计算机科学, no. 04, 15 April 2017 (2017-04-15)*

Similar Documents

PublicationPublication DateTitle
CN113283426B (en)Embedded target detection model generation method based on multi-target neural network search
CN109190446A (en)Pedestrian's recognition methods again based on triple focused lost function
CN107392241B (en)Image target classification method based on weighted column sampling XGboost
CN109299664B (en) A Re-ranking Method for Person Re-identification
CN104035996B (en)Field concept abstracting method based on Deep Learning
CN113313250B (en) Neural network training method and system using mixed precision quantification and knowledge distillation
WO2022160772A1 (en)Person re-identification method based on view angle guidance multi-adversarial attention
CN113741886A (en)Statement level program repairing method and system based on graph
CN113822318B (en) Neural network adversarial training method, device, computer equipment and storage medium
CN116910656A (en) A log anomaly detection method based on machine learning
KR20200117690A (en)Method and Apparatus for Completing Knowledge Graph Based on Convolutional Learning Using Multi-Hop Neighborhoods
CN108596118A (en)A kind of Remote Image Classification and system based on artificial bee colony algorithm
KR102273136B1 (en)Method and Apparatus for Completing Zero-Shot Knowledge Graph Using Multi-Hop Neighborhoods
CN115132280A (en) Local structure discovery system of causal network based on weak prior knowledge
CN119201131A (en) A method and system for iterative use of code snippet extraction based on parallelization
CN110705695B (en) Method, device, device and storage medium for searching model structure
CN110502669B (en)Social media data classification method and device based on N-edge DFS subgraph lightweight unsupervised graph representation learning
CN117152527A (en) A target detection method for sparsely labeled remote sensing images based on graph combination optimization
CN115983375A (en)Transfer learning method and device based on domain pair association
Yuan et al.Uncertainty-based network for few-shot image classification
CN112232482A (en) A method, device and smart device for building neural network architecture search
CN118838846B (en) A method for building a large model in the field of software testing
CN119761381B (en) Sentiment analysis model training method, device, storage medium and electronic device
CN115617693B (en)Deep learning library interface test method based on particle swarm optimization
WO2025061084A1 (en)Systems, apparatuses, methods, and non-transitory computer-readable storage devices for optimizing artificial neural network

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp