CN110874308B - Method and device for generating unique value - Google Patents

Method and device for generating unique value Download PDF

Info

Publication number
CN110874308B
CN110874308B CN201811010992.0A CN201811010992A CN110874308B CN 110874308 B CN110874308 B CN 110874308B CN 201811010992 A CN201811010992 A CN 201811010992A CN 110874308 B CN110874308 B CN 110874308B
Authority
CN
China
Prior art keywords
unique value
test program
prefix
server
thread
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.)
Active
Application number
CN201811010992.0A
Other languages
Chinese (zh)
Other versions
CN110874308A (en
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201811010992.0A priority Critical patent/CN110874308B/en
Publication of CN110874308A publication Critical patent/CN110874308A/en
Application granted granted Critical
Publication of CN110874308B publication Critical patent/CN110874308B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • G06F11/3414Workload generation, e.g. scripts, playback
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a device for generating a unique value, and relates to the technical field of computers. One embodiment of the method comprises the following steps: obtaining a unique value prefix according to the server IP and the subnet mask of the test executor of the test program and the process number and the thread number of the test program; and accumulating the execution times of the test program as a unique value suffix in the execution process of the test program, and generating the unique value executed by the current test program according to the unique value suffix executed by the current test program and the unique value prefix. The embodiment can avoid the problem that the unique value is not unique, and does not influence the performance index of the performance test.

Description

Method and device for generating unique value
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for generating a unique value.
Background
The problem of generating a unique value is frequently encountered in the field of performance test, and the generation of the unique value is generally realized by adopting two methods, namely, the generation is performed in an accumulated way by utilizing third-party software, and the unique value is obtained by locking and remote procedure calling modes; another approach is to use a relatively precise time, such as generating a time series in microseconds as a unique value.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art: based on the remote procedure call of locking, a global unique value can be obtained, but the locking and the remote procedure call occupy a certain time and can influence the performance index of the performance test. Based on the accurate time, the obtained unique value may generate global non-unique situation during the concurrency of the cross-process and the cross-server, at this time, the remote process mode needs to be called to inquire whether the unique value is unique or not, if the unique value is a repeated value, the unique value is discarded, and performance loss is caused.
Therefore, a method and apparatus for generating unique values are needed to avoid the problem of non-unique values and not to affect the performance index of the performance test.
Disclosure of Invention
In view of this, the embodiments of the present invention provide a method and apparatus for generating a unique value, which can avoid the problem that the unique value is not unique, and does not affect the performance index of the performance test.
To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided a method of generating a unique value, including:
obtaining a unique value prefix according to the server IP and the subnet mask of the test executor of the test program and the process number and the thread number of the test program;
and accumulating the execution times of the test program as a unique value suffix in the execution process of the test program, and generating the unique value executed by the current test program according to the unique value suffix executed by the current test program and the unique value prefix.
Optionally, the unique value prefix includes: a server prefix number, a process prefix number, and a thread prefix number;
the server IP and subnet mask of the test executor according to the test program, and the process number and thread number of the test program, so as to obtain the unique value prefix include:
when the process of the test program is started, acquiring a server IP and a subnet mask of a test execution machine of the test program, generating a server prefix number, acquiring a process number of the test program, and generating a process prefix number;
after the thread of the test program is started, the thread number of the test program is obtained, and the thread prefix number is generated.
Optionally, the obtaining the server IP and the subnet mask of the test executor of the test program, and generating the server prefix number includes:
converting each digit of the server IP and the subnet mask into a binary number with a set digit number, wherein the set digit number is more than or equal to 8 digits;
performing OR operation on each binary number of the server IP and the corresponding binary number of the subnet mask to obtain an OR operation result, and performing exclusive OR operation on each binary number of the OR operation result and the corresponding binary number of the subnet mask to obtain an exclusive OR operation result;
and converting the exclusive-or operation result into decimal numbers, and summing all the numbers to obtain the server prefix number.
Optionally, the generating the unique value executed by the current test program according to the unique value suffix and the unique value prefix of the current test program includes:
and forming a character string from the number of server prefixes, the number of process prefixes, the number of thread prefixes and the execution times of the test program executed at the present time to generate a numerical unique value, wherein an interval number is arranged between every two numbers in the character string to distinguish the number of server prefixes, the number of process prefixes, the number of thread prefixes and the execution times in the character string.
Optionally, the generating, as the unique value suffix, the unique value executed by the current test program according to the unique value suffix executed by the current test program and the unique value prefix further includes:
converting the numerical unique value into a set binary number, wherein the set binary number is larger than decimal;
and replacing each digit of the set digit with a non-numeric character according to the numerical value of each digit of the set digit to obtain a non-numeric unique value.
To achieve the above object, according to another aspect of an embodiment of the present invention, there is also provided an apparatus for generating a unique value, including:
the prefix acquisition module is used for acquiring a unique value prefix according to the server IP and the subnet mask of the test execution machine of the test program and the process number and the thread number of the test program;
and the unique value generating module is used for accumulating the execution times of the test program as a unique value suffix in the execution process of the test program, and generating the unique value executed by the current test program according to the unique value suffix executed by the current test program and the unique value prefix.
Optionally, the unique value prefix includes: a server prefix number, a process prefix number, and a thread prefix number;
the prefix acquisition module is further used for acquiring a server IP and a subnet mask of a test executor of the test program when the process of the test program is started, generating a server prefix number, acquiring a process number of the test program and generating a process prefix number;
after the thread of the test program is started, the thread number of the test program is obtained, and the thread prefix number is generated.
Optionally, the unique value generating module is further configured to convert each of the numbers of the server IP and the subnet mask into a binary number with a set number of bits, where the set number of bits is greater than or equal to 8 bits;
performing OR operation on each binary number of the server IP and the corresponding binary number of the subnet mask to obtain an OR operation result, and performing exclusive OR operation on each binary number of the OR operation result and the corresponding binary number of the subnet mask to obtain an exclusive OR operation result;
and converting the exclusive-or operation result into decimal numbers, and summing all the numbers to obtain the server prefix number.
Optionally, the unique value generating module is further configured to form a string from the number of server prefixes, the number of process prefixes, the number of thread prefixes, and the number of times the test program is executed at the present time, so as to generate a numerical unique value, where an interval number is set between every two digits in the string, so as to distinguish the number of server prefixes, the number of process prefixes, the number of thread prefixes, and the number of times of execution in the string.
Optionally, the unique value generating module is further configured to convert the numerical unique value into a set binary number, where the set binary number is greater than decimal;
and replacing each digit of the set digit with a non-numeric character according to the numerical value of each digit of the set digit to obtain a non-numeric unique value.
To achieve the above object, according to another aspect of an embodiment of the present invention, there is also provided an electronic device that generates a unique value, including:
one or more processors;
storage means for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the methods of generating unique values provided by the present invention.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is also provided a computer-readable medium having stored thereon a computer program which, when executed by a processor, implements the method of generating a unique value provided by the present invention.
The method and the device for generating the unique value provided by the invention have the advantages that the accumulation process is carried out in each thread, the accumulation locking is not needed, the time loss of remote equation process call is avoided, the application program interface for calling the operating system is also needed to be carried out once when the process and the thread are initialized, the performance test is not influenced, and the execution time of the performance test script is not needed to be considered. Because the unique value does not adopt a time sequence value, the final unique value has smaller length and can be suitable for more scenes. The method can also compress and convert the numerical unique value into a non-numerical unique value, the compression process is carried out before the performance test script is called, remote procedure call is not needed, the running time of performance test is not affected, a part of network bandwidth can be saved because the whole compressed character string is shortened, and the requirement of limiting the length of the unique value of some service data can be met particularly when the generated unique value does not generate the unique data in the performance test script.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a method for generating unique values provided by an embodiment of the present invention;
FIG. 2 is a schematic diagram of the main modules of an apparatus for generating unique values provided by an embodiment of the present invention;
FIG. 3 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 4 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The embodiment of the invention provides a method for generating a unique value, which can be applied to an application scene of performance test, wherein in the scene, when script codes of the performance test are called each time, the unique value called each time is generated to serve as the entry of the performance test codes.
As shown in fig. 1, the method for generating the unique value includes: step S101 and step S102. In step S101, a unique value prefix is obtained from the server IP and the subnet mask of the test executor of the test program, and the process number and the thread number of the test program.
Server IP and subnet masks may be used to distinguish between different test executors, i.e., servers, process numbers and thread numbers may be used to distinguish between different process numbers and thread numbers on a test executor. Thus, the unique value prefix is unique to a test program executing on a thread within a process on a server.
Further, in step S102, the number of times of execution of the test program is accumulated as a unique value suffix during the execution of the test program, and a unique value for the current test program execution is generated from the unique value suffix and the unique value prefix of the current test program execution.
After the operating system starts the process, a thread local variable is initialized for the thread for counting the number of calls, the value being initialized to 0. When the thread calls the test program (script code of performance test), the call number variable in the thread is accumulated by 1, then the performance test code is called, and the above process is repeated until the performance test is finished.
For a test program executed on a thread in a process on a server, the position value suffix of each execution is unique, so that the unique value is obtained through the combination of the unique value prefix and the suffix, and the test program is unique for any test program when executing each time.
In one embodiment of the invention, the unique value prefix includes: server prefix number, process prefix number, and thread prefix number.
In step S101, the process of obtaining the unique value prefix according to the server IP and the subnet mask of the test executor of the test program, and the process number and the thread number of the test program is specifically:
when the process of the test program is started, the server IP and the subnet mask of the test execution machine of the test program are obtained, the number of the server prefixes is generated, the process number of the test program is obtained, and the number of the process prefixes is generated.
The process of generating the server prefix number specifically includes: first, each of the numbers of the server IP and the subnet mask is converted into a binary number of a set number of bits, which is 8 bits or more. Then, each binary number of the server IP is subjected to OR operation with the corresponding binary number of the subnet mask to obtain an OR operation result, and each binary number of the OR operation result is subjected to XOR operation with the corresponding binary number of the subnet mask to obtain an XOR operation result.
And converting the exclusive-or operation result into decimal numbers, and summing all the numbers to obtain the server prefix number.
When the performance test is executed, different performance test executors are allocated to perform concurrent performance tests. At the start of the performance test procedure, the IP of its server and the subnet mask, e.g., IP address 192.168.0.100, are first obtained, the subnet mask being 255.255.255.0. Both are converted into binary numbers, 8 bits per group, with the insufficient positions preceded by 0.
The IP address is: 11000000.10101000,00000000.01100100;
the subnet mask is: 11111111.11111111.11111111.00000000;
the two are bit or operated, and the result is 11111111.11111111,11111111.01100100;
and performing exclusive OR operation on the result and the subnet mask again to obtain:
00000000.00000000.00000000.01100100;
finally, the binary system is converted into a 10-system number which is 0.0.0.100, and each group of numbers is added, namely 0+0+0+100 is 100, and the sum result is taken as the server prefix number of the unique value, and the value is used for distinguishing the unique value generated by different servers and is put into a global variable.
After the thread of the test program is started, the thread number of the test program is obtained, and the thread prefix number is generated.
The present invention is directed to processing an IP and a subnet mask of a server, and has a main object to shorten an address as much as possible while maintaining the uniqueness of the IP and the subnet mask of the server.
After the operating system starts the process, at least one main thread is provided, and a multithreading is started during performance test to achieve the aim of better concurrency, and the real performance calling environment can be simulated truly.
The thread will then initialize a thread local variable for the call count, which is initialized to 0.
In one embodiment of the present invention, the process of generating the unique value executed by the present test program according to the unique value suffix and the unique value prefix executed by the present test program specifically includes: and forming a character string from the number of server prefixes, the number of process prefixes, the number of thread prefixes and the execution times of the test program executed at the present time to generate a numerical unique value, wherein an interval number is arranged between every two numbers in the character string to distinguish the number of server prefixes, the number of process prefixes, the number of thread prefixes and the execution times in the character string.
For example, the string is a server prefix value+0+process number prefix value+0+thread number prefix value+0+number of calls, and the middle 0 value is an interval number, which is used to distinguish different data items, so as to avoid the situation that the result is not unique after the data of different data items are combined, for example, the process number is 101, the thread number is 11, and the process number is 1011, and the thread number is 1, if the data items are not distinguished, the result is 10111, and for related variables in the scheme, no number of 0 head exists, so that the number 0 is adopted as the interval number of the data items, and the characteristic that the whole is unique data is not affected.
The method for generating the unique value provided by the invention has the advantages that the accumulation process is carried out in each thread, the accumulation locking is not needed, the time loss of remote equation process call is avoided, the application program interface of the calling operation system is carried out once when the process and the thread are initialized, the performance test is not influenced, and the execution time of the performance test script is not needed to be considered. Because the unique value does not adopt a time sequence value, the final unique value has smaller length and can be suitable for more scenes.
For non-numeric unique value generation, the present scheme may also compress the decimal digital conversion. The compression method is as follows: converting the generated unique value into a set binary number, setting the binary number to be larger than decimal, and replacing each digit of the set binary number with a non-numeric character according to the numeric value of each digit of the set binary number to obtain a non-numeric unique value.
And giving different characters according to the set number size of each digit of the set system according to the conversion rule of the compression dictionary to obtain a result character string, namely the unique value code after compression.
The compression process is executed before the performance test script is called, remote procedure call is not needed, the running time of performance test is not affected, and as the whole compressed character string is shortened, a part of network bandwidth can be saved, and especially when the generated unique value does not generate unique data in the performance test script, the requirement of limiting the length of the unique value of some service data can be met.
The embodiment of the present invention further provides an apparatus for generating a unique value, as shown in fig. 2, the apparatus 200 includes: a prefix acquisition module 201 and a unique value generation module 202.
The prefix acquisition module 201 is configured to obtain a unique value prefix according to a server IP and a subnet mask of a test executor of the test program, and a process number and a thread number of the test program.
The unique value generating module 202 is configured to accumulate the execution times of the test program as a unique value suffix during the execution of the test program, and generate the unique value executed by the current test program according to the unique value suffix and the unique value prefix executed by the current test program.
In the present invention, the unique value prefix includes: server prefix number, process prefix number, and thread prefix number.
The prefix acquisition module is further used for acquiring the server IP and the subnet mask of the test execution machine of the test program when the process of the test program is started, generating the server prefix number, acquiring the process number of the test program and generating the process prefix number.
After the thread of the test program is started, the thread number of the test program is obtained, and the thread prefix number is generated.
In the present invention, the unique value generation module is further configured to convert each of the numbers of the server IP and the subnet mask into a binary number of a set number of bits, the set number of bits being 8 bits or more.
And performing OR operation on each binary number of the server IP and the corresponding binary number of the subnet mask to obtain an OR operation result, and performing exclusive OR operation on each binary number of the OR operation result and the corresponding binary number of the subnet mask to obtain an exclusive OR operation result.
And converting the exclusive-or operation result into decimal numbers, and summing all the numbers to obtain the server prefix number.
In the invention, the unique value generating module is further used for forming a character string from the number of server prefixes, the number of process prefixes, the number of thread prefixes and the execution times of the test program executed at the present time to generate a numerical unique value, and interval numbers are arranged between every two numbers in the character string to distinguish the number of server prefixes, the number of process prefixes, the number of thread prefixes and the execution times in the character string.
In the invention, the unique value generation module is further used for converting the numerical unique value into a set system number, wherein the set system is larger than decimal.
And replacing each digit of the set digit with a non-numeric character according to the numerical value of each digit of the set digit to obtain a non-numeric unique value.
The method and the device for generating the unique value provided by the invention have the advantages that the accumulation process is carried out in each thread, the accumulation locking is not needed, the time loss of remote equation process call is avoided, the application program interface for calling the operating system is also needed to be carried out once when the process and the thread are initialized, the performance test is not influenced, and the execution time of the performance test script is not needed to be considered. Because the unique value does not adopt a time sequence value, the final unique value has smaller length and can be suitable for more scenes. The method can also compress and convert the numerical unique value into a non-numerical unique value, the compression process is carried out before the performance test script is called, remote procedure call is not needed, the running time of performance test is not affected, a part of network bandwidth can be saved because the whole compressed character string is shortened, and the requirement of limiting the length of the unique value of some service data can be met particularly when the generated unique value does not generate the unique data in the performance test script.
Fig. 3 illustrates an exemplary system architecture 300 to which the method of generating a unique value or the apparatus of generating a unique value of embodiments of the present invention may be applied.
As shown in fig. 3, the system architecture 300 may include terminal devices 301, 302, 303, a network 304, and a server 305. The network 304 is used as a medium to provide communication links between the terminal devices 301, 302, 303 and the server 305. The network 304 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 305 via the network 304 using the terminal devices 301, 302, 303 to receive or send messages or the like. Various communication client applications may be installed on the terminal devices 301, 302, 303.
The terminal devices 301, 302, 303 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 305 may be a server providing various services, such as a background management server generating a unique value for test program execution from a server IP and a subnet mask of a test executor of the test program, and a process number and a thread number of the test program, and the number of times the test program is executed.
It should be noted that, the method for generating the unique value provided in the embodiment of the present invention is generally executed by the server 305, and accordingly, the device for generating the unique value is generally disposed in the server 305.
It should be understood that the number of terminal devices, networks and servers in fig. 3 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 4, there is illustrated a schematic diagram of a computer system 400 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 4 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 4, the computer system 400 includes a Central Processing Unit (CPU) 401, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 402 or a program loaded from a storage section 408 into a Random Access Memory (RAM) 403. In RAM 403, various programs and data required for the operation of system 400 are also stored. The CPU 401, ROM 402, and RAM 403 are connected to each other by a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
The following components are connected to the I/O interface 405: an input section 406 including a keyboard, a mouse, and the like; an output portion 407 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker, and the like; a storage section 408 including a hard disk or the like; and a communication section 409 including a network interface card such as a LAN card, a modem, or the like. The communication section 409 performs communication processing via a network such as the internet. The drive 410 is also connected to the I/O interface 405 as needed. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed on the drive 410 as needed, so that a computer program read therefrom is installed into the storage section 408 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 409 and/or installed from the removable medium 411. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 401.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor includes a prefix acquisition module and a unique value generation module. The names of these modules do not constitute a limitation on the module itself in some cases.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include:
obtaining a unique value prefix according to the server IP and the subnet mask of the test executor of the test program and the process number and the thread number of the test program;
and accumulating the execution times of the test program as a unique value suffix in the execution process of the test program, and generating the unique value executed by the current test program according to the unique value suffix executed by the current test program and the unique value prefix.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (12)

1. A method of generating a unique value, comprising:
obtaining a unique value prefix according to the server IP and the subnet mask of the test executor of the test program and the process number and the thread number of the test program;
accumulating the execution times of the test program as a unique value suffix in the execution process of the test program, and generating a unique value executed by the current test program according to the unique value suffix executed by the current test program and the unique value prefix; after the process is started, a thread local variable is initialized for the thread and used for counting the calling times.
2. The method of claim 1, wherein the unique value prefix comprises: a server prefix number, a process prefix number, and a thread prefix number;
the obtaining the unique value prefix according to the server IP and the subnet mask of the test executor of the test program, and the process number and the thread number of the test program includes:
when the process of the test program is started, acquiring a server IP and a subnet mask of a test execution machine of the test program, generating a server prefix number, acquiring a process number of the test program, and generating a process prefix number;
after the thread of the test program is started, the thread number of the test program is obtained, and the thread prefix number is generated.
3. The method of claim 2, wherein the obtaining the server IP and subnet mask of the test executor of the test program, generating the server prefix number comprises:
converting each digit of the server IP and the subnet mask into a binary number with a set digit number, wherein the set digit number is more than or equal to 8 digits;
performing OR operation on each binary number of the server IP and the corresponding binary number of the subnet mask to obtain an OR operation result, and performing exclusive OR operation on each binary number of the OR operation result and the corresponding binary number of the subnet mask to obtain an exclusive OR operation result;
and converting the exclusive-or operation result into decimal numbers, and summing all the numbers to obtain the server prefix number.
4. The method of claim 1, wherein generating the unique value for the current test program execution based on the unique value suffix and the unique value prefix for the current test program execution comprises:
and forming a character string from the number of server prefixes, the number of process prefixes, the number of thread prefixes and the execution times of the test program executed at the present time to generate a numerical unique value, wherein an interval number is arranged between every two numbers in the character string to distinguish the number of server prefixes, the number of process prefixes, the number of thread prefixes and the execution times in the character string.
5. The method of claim 4, wherein generating the unique value for the current test program execution based on the unique value suffix and the unique value prefix for the current test program execution further comprises:
converting the numerical unique value into a set binary number, wherein the set binary number is larger than decimal;
and replacing each digit of the set digit with a non-numeric character according to the numerical value of each digit of the set digit to obtain a non-numeric unique value.
6. An apparatus for generating a unique value, comprising:
the prefix acquisition module is used for acquiring a unique value prefix according to the server IP and the subnet mask of the test execution machine of the test program and the process number and the thread number of the test program;
the unique value generating module is used for accumulating the execution times of the test program as a unique value suffix in the execution process of the test program, and generating the unique value executed by the current test program according to the unique value suffix executed by the current test program and the unique value prefix; after the process is started, a thread local variable is initialized for the thread and used for counting the calling times.
7. The apparatus of claim 6, wherein the unique value prefix comprises: a server prefix number, a process prefix number, and a thread prefix number;
the prefix acquisition module is further used for acquiring a server IP and a subnet mask of a test executor of the test program when the process of the test program is started, generating a server prefix number, acquiring a process number of the test program and generating a process prefix number;
after the thread of the test program is started, the thread number of the test program is obtained, and the thread prefix number is generated.
8. The apparatus of claim 7, wherein the unique value generation module is further configured to convert each of the server IP and the subnet mask into a binary number of a set number of bits, the set number of bits being 8 bits or more;
performing OR operation on each binary number of the server IP and the corresponding binary number of the subnet mask to obtain an OR operation result, and performing exclusive OR operation on each binary number of the OR operation result and the corresponding binary number of the subnet mask to obtain an exclusive OR operation result;
and converting the exclusive-or operation result into decimal numbers, and summing all the numbers to obtain the server prefix number.
9. The apparatus of claim 6, wherein the unique value generation module is further configured to form a string of the number of server prefixes, the number of process prefixes, the number of thread prefixes, and the number of executions of the test program at the time of execution, to generate a numerical unique value, and an interval number is provided between each two numbers in the string to distinguish the number of server prefixes, the number of process prefixes, the number of thread prefixes, and the number of executions in the string.
10. The apparatus of claim 9, wherein the unique value generation module is further configured to convert the numeric unique value to a set-up number, the set-up number being greater than decimal;
and replacing each digit of the set digit with a non-numeric character according to the numerical value of each digit of the set digit to obtain a non-numeric unique value.
11. An electronic device that generates a unique value, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-5.
12. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-5.
CN201811010992.0A 2018-08-31 2018-08-31 Method and device for generating unique value Active CN110874308B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811010992.0A CN110874308B (en) 2018-08-31 2018-08-31 Method and device for generating unique value

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811010992.0A CN110874308B (en) 2018-08-31 2018-08-31 Method and device for generating unique value

Publications (2)

Publication Number Publication Date
CN110874308A CN110874308A (en) 2020-03-10
CN110874308B true CN110874308B (en) 2024-02-06

Family

ID=69715314

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811010992.0A Active CN110874308B (en) 2018-08-31 2018-08-31 Method and device for generating unique value

Country Status (1)

Country Link
CN (1) CN110874308B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113239043B (en) * 2021-05-17 2024-05-03 上海中通吉网络技术有限公司 Method and apparatus for efficient generation of unique values in a distributed system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104025029A (en) * 2011-12-30 2014-09-03 英特尔公司 Unique packed data element identification processors, methods, systems, and instructions
CN104113435A (en) * 2014-07-04 2014-10-22 广州华多网络科技有限公司 Method and device for generating identifier
CN106572165A (en) * 2016-10-26 2017-04-19 宜人恒业科技发展(北京)有限公司 Distributed global unique ID application method
CN106657441A (en) * 2017-01-11 2017-05-10 深圳证券通信有限公司 Algorithm for generating unique packet ID of financial data exchange message
CN106776932A (en) * 2016-12-01 2017-05-31 湖北荆楚网络科技股份有限公司 A kind of method that unique ID is generated in distributed system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180041224A1 (en) * 2016-08-04 2018-02-08 International Business Machines Corporation Data value suffix bit level compression

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104025029A (en) * 2011-12-30 2014-09-03 英特尔公司 Unique packed data element identification processors, methods, systems, and instructions
CN104113435A (en) * 2014-07-04 2014-10-22 广州华多网络科技有限公司 Method and device for generating identifier
CN106572165A (en) * 2016-10-26 2017-04-19 宜人恒业科技发展(北京)有限公司 Distributed global unique ID application method
CN106776932A (en) * 2016-12-01 2017-05-31 湖北荆楚网络科技股份有限公司 A kind of method that unique ID is generated in distributed system
CN106657441A (en) * 2017-01-11 2017-05-10 深圳证券通信有限公司 Algorithm for generating unique packet ID of financial data exchange message

Also Published As

Publication number Publication date
CN110874308A (en) 2020-03-10

Similar Documents

Publication Publication Date Title
CN108628898B (en) Method, device and equipment for data storage
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN108874825B (en) Abnormal data verification method and device
CN110795328A (en) Interface testing method and device
CN111104776A (en) Floating point number processing method and device and electronic equipment
CN110874308B (en) Method and device for generating unique value
CN112995199B (en) Data encoding and decoding method, device, transmission system, terminal equipment and storage medium
US12086107B2 (en) File sharing method, apparatus, and system
US8018359B2 (en) Conversion of bit lengths into codes
CN109087097B (en) Method and device for updating same identifier of chain code
CN111314351A (en) Anti-crawler data processing method and device, electronic equipment and storage medium
CN107643906A (en) Data processing method and device
CN112214500A (en) Data comparison method and device, electronic equipment and storage medium
CN114968170A (en) Method for generating fixed sum of floating point number, related device and computer program product
CN113283991B (en) Processing method and device for transaction data on blockchain
CN115063123A (en) Intelligent manufacturing method and system and electronic equipment
CN111026629A (en) Method and device for automatically generating test script
CN111209042B (en) Method, device, medium and electronic equipment for establishing function stack
CN113204683A (en) Information reconstruction method and device, storage medium and electronic equipment
CN111984612A (en) Method, device and system for sharing files
CN113850988B (en) Key value correction method, device, equipment and computer readable medium
CN113760343A (en) Method and device for processing service request
CN113469683B (en) Key storage method and device, electronic equipment and storage medium
CN107562442B (en) Method and device for reading data
CN113472565B (en) Method, apparatus, device and computer readable medium for expanding server function

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant