CN113821426B - Block chain performance test method and device - Google Patents

Block chain performance test method and device Download PDF

Info

Publication number
CN113821426B
CN113821426B CN202111389088.7A CN202111389088A CN113821426B CN 113821426 B CN113821426 B CN 113821426B CN 202111389088 A CN202111389088 A CN 202111389088A CN 113821426 B CN113821426 B CN 113821426B
Authority
CN
China
Prior art keywords
transaction
thread
threads
total amount
block chain
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
CN202111389088.7A
Other languages
Chinese (zh)
Other versions
CN113821426A (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.)
Nanjing Jinninghui Technology Co ltd
Original Assignee
Nanjing Jinninghui 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 Nanjing Jinninghui Technology Co ltd filed Critical Nanjing Jinninghui Technology Co ltd
Priority to CN202111389088.7A priority Critical patent/CN113821426B/en
Publication of CN113821426A publication Critical patent/CN113821426A/en
Application granted granted Critical
Publication of CN113821426B publication Critical patent/CN113821426B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/3419Recording 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 by assessing time
    • 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
    • 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
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a block chain performance test method and a device, wherein the method comprises the steps of receiving input test parameters; creating threads with the same number as the concurrent number, and constructing respective test data by each thread; the thread carries out hash and signature on respective test data; constructing a complete transaction body; distributing the sub transaction bodies of all the threads to block chain nodes corresponding to the threads; recording a first transaction total amount and a first current time received in the block chain at intervals of a first interval period, and pressing the first transaction total amount and the first current time into a TPS stack; recording a second transaction total amount and a second current time received in the block chain at intervals of a second interval period, and pressing the second transaction total amount and the second current time into the CTPS stack; mean TPS, mean CTPS, real-time TPS and real-time CTPS are calculated. According to the method and the device, the test transaction for the performance test can be conveniently constructed, the TPS and the CTPS can be monitored and obtained in real time, and the problems that transaction data cannot be conveniently constructed and the CTPS cannot be measured by a block chain performance test tool in the prior art are solved.

Description

Block chain performance test method and device
Technical Field
The present application relates to the field of block chain technologies, and in particular, to a block chain performance testing method and apparatus.
Background
When testing the performance of the blockchain, commonly used performance testing tools are Jmeter, loadRunner and the like. These conventional testing tools typically capture the user's traffic and eventually script it. The specific implementation process may be that test data for the script is constructed in advance, after the script is started, the data is read as a parameter for transmission of the interface, the interface is accessed in a simulation manner, important indexes such as response time of the interface are recorded, and finally, average response time, response median, real-time TPS (i.e., abbreviation of Transactions Per Second), average TPS, and the like are calculated. Such indexes will be used as important references for the performance of the interface, and are used for measuring the performance condition of the interface.
However, in the above-mentioned conventional performance tool, the hash and signature fields in the blockchain transaction cannot be quickly constructed. Because the transaction data is real-time and dynamic, any change can be reflected in the hash and signature fields of the transaction, when sample data is constructed, a great deal of effort is needed to generate a large number of transaction data bodies in advance, the hash and the signature are calculated one by one and then are imported into the script, but the constructed transaction data is static, the real hash and the data bodies are different due to the change of any item, the calling parameters, the calling sequence and the like are common steps in a real test case scene, the hash can be changed when one parameter is adjusted, the sample data prepared in advance needs to be hashed again and signed, and the operation is troublesome and low in efficiency.
Although the above-mentioned conventional performance tool can test the performance of the conventional interface, the transaction of the blockchain is processed asynchronously, i.e. after the transaction interface is called and sent, a transaction certificate is returned immediately, so that the interface call is ended. And the subsequent block chain can process the transaction, including the steps of signature checking, execution, packaging, consensus, confirmation and the like, and finally the transaction is landed in the block chain account book, so that the whole transaction period is finished. For the performance index of the transaction processing flow after the interface call, it is referred to as CTPS (coordinated Transactions Per Second, abbreviated as CTPS), and such tools cannot be tested, and the testing tools in the prior art cannot conveniently construct transaction data.
Disclosure of Invention
The application provides a block chain performance testing method and device, which are used for solving the problems that a block chain performance testing tool in the prior art cannot conveniently construct transaction data and cannot test CTPS.
In a first aspect, the present application provides a method for testing performance of a block chain, including:
receiving test parameters input by a user, and triggering a starting instruction to a data construction module if the test parameter configuration is completed; the test parameters comprise transaction core parameters and concurrency numbers in pressure measurement;
after receiving a starting instruction, creating threads with the same number as the concurrent number, and constructing respective test data by each thread;
the thread carries out hash and signature on respective test data, and the hash and signature are preset according to different block chain bottom layers; constructing a complete transaction body according to the test data, the hash and the signature, wherein the complete transaction body is composed of sub transaction bodies of each thread;
each thread stores the sub transaction bodies in the respective storage space, and after the sub transaction bodies of all threads are constructed, a sending instruction is sent to the data sending module;
receiving a sending instruction, distributing the sub-transaction bodies of all threads to the block chain link points corresponding to the threads, and sending a performance acquisition instruction to a performance analysis module;
after receiving a performance acquisition instruction, recording a first transaction total amount and a first current time received in a block chain at intervals of a first interval period, and pressing the first transaction total amount and the first current time into a TPS stack; the first transaction total amount comprises the number of confirmed sub-transaction bodies and the number of unconfirmed sub-transaction bodies;
recording a second transaction total amount and a second current time received in the block chain every a second interval period, and pressing the second transaction total amount and the second current time into the CTPS stack; the second transaction total amount is the number of the confirmed sub transaction bodies;
and calculating average TPS, average CTPS, real-time TPS and real-time CTPS according to parameters in the TPS stack and the CTPS stack and a preset program.
Further, the method further comprises: thread sharing locks are utilized to control blocking of individual threads.
Further, the thread sharing lock is CountDownLatch.
Further, utilizing the thread sharing lock CountDownLatch to control blocking of each thread includes:
detecting that some threads are executed completely, and sending a pause instruction to the completed threads by using the thread sharing lock;
and after the execution of the unfinished thread is finished, canceling the pause instruction to control the blocking of each thread.
Further, the method further comprises: and controlling each thread to release the thread sharing lock so as to enable all the threads to be in an execution state, and simulating the concurrency number according to the execution state of the threads.
Further, distributing the sub transaction bodies of the threads to the block chain nodes corresponding to the threads, including:
acquiring the thread number of each thread, and performing modulus calculation according to the thread number of each thread to obtain a modulus result;
and distributing the sub transaction bodies to the block chain nodes corresponding to the threads according to the modulus taking result.
Further, the method further comprises: when the first transaction total amount is the same as a first stack top value in the TPS stack, stopping pressing the first transaction total amount and the first current time into the TPS stack;
and when the second transaction total amount is the same as a second stack top value in the CTPS stack, stopping pushing the second transaction total amount and the second current time into the CTPS stack.
Further, threads are executed out-of-order.
Further, the memory space is threaded local, which is a memory class inside the thread.
In a second aspect, the present application further provides a device for testing performance of a block chain, where the device is configured to perform the method, and the device includes a parameter input module, a data construction module, a data transmission module, and a performance analysis module, where:
the parameter input module is configured to perform the following steps: receiving test parameters input by a user, and triggering a starting instruction to a data construction module if the test parameter configuration is completed; the test parameters comprise transaction core parameters and concurrency numbers in pressure measurement;
the data construction module is configured to perform the steps of: after receiving a starting instruction, creating threads with the same number as the concurrent number, and constructing respective test data by each thread;
the thread carries out hash and signature on respective test data, and the hash and signature are preset according to different block chain bottom layers;
constructing a complete transaction body according to the test data, the hash and the signature, wherein the complete transaction body is composed of sub transaction bodies of each thread;
each thread stores the sub transaction bodies in the respective storage space, and after the sub transaction bodies of all threads are constructed, a sending instruction is sent to the data sending module;
the data transmission module is configured to perform the steps of: receiving a sending instruction, distributing the sub-transaction bodies of all threads to the block chain link points corresponding to the threads, and sending a performance acquisition instruction to a performance analysis module;
the performance analysis module is configured to perform the steps of:
after receiving a performance acquisition instruction, recording a first transaction total amount and a first current time received in a block chain at intervals of a first interval period, and pressing the first transaction total amount and the first current time into a TPS stack; the first transaction total amount comprises the number of confirmed sub-transaction bodies and the number of unconfirmed sub-transaction bodies;
recording a second transaction total amount and a second current time received in the block chain every a second interval period, and pressing the second transaction total amount and the second current time into the CTPS stack; the second transaction total amount is the number of the confirmed sub transaction bodies;
and calculating average TPS, average CTPS, real-time TPS and real-time CTPS according to parameters and preset programs in the TPS stack and the CTPS stack.
According to the technical scheme, the method and the device for testing the performance of the block chain are provided, and the method comprises the steps of receiving test parameters input by a user; creating threads with the same number as the concurrent number, and constructing respective test data by each thread; the thread carries out hash and signature on respective test data; constructing a complete transaction body according to the test data, the hash and the signature; distributing the sub transaction bodies of all the threads to block chain nodes corresponding to the threads; recording a first transaction total amount and a first current time received in a block chain at intervals of a first interval period, and pressing the first transaction total amount and the first current time into a TPS stack; recording a second transaction total amount and a second current time received in the block chain every a second interval period, and pressing the second transaction total amount and the second current time into the CTPS stack; and calculating average TPS, average CTPS, real-time TPS and real-time CTPS according to parameters in the TPS stack and the CTPS stack and a preset program. Through the application, the test transaction for the performance test can be conveniently constructed, the efficiency of constructing the transaction data body is greatly improved, and two performance indexes of TPS and CTPS can be calculated, monitored and obtained in real time, so that the problems that the transaction data cannot be conveniently constructed and the CTPS cannot be measured by the block chain performance test tool in the prior art are solved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flow chart of a block chain performance testing method according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart illustrating a process of controlling blocking of each thread by using a thread sharing lock CountDownLatch according to an embodiment of the present application;
fig. 3 is a schematic flow chart illustrating a process of distributing transaction sub-volumes of respective threads to corresponding block chain nodes of the threads according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a block chain performance testing apparatus according to an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application. The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Due to the irreversibility and strong uniqueness of the block chain transaction hash algorithm, and the security of the block chain, which requires double authentication of the hash and signature of the transaction, the conventional general performance tool cannot conveniently construct transaction data, and further perform performance test on the block chain, and cannot measure the number of uplink Transactions Per Second (CTPS).
By the method and the device, the test transaction for the performance test can be conveniently constructed, and the efficiency of constructing the transaction data body is greatly improved. The method and the device meet the requirement of block chain performance test, monitor and acquire performance index dimensions TPS (Transactions Per Second, namely the number of Transactions processed by the server Per Second) and CTPS (China telecom services platform) defined by the block chain in real time, greatly reduce the test difficulty of the block chain performance, and further accurately master the macro performance of the block chain system.
Fig. 1 is a schematic flow chart of a block chain performance testing method according to an embodiment of the present application, and as shown in fig. 1, the block chain performance testing method includes:
s1: receiving test parameters input by a user, and triggering a starting instruction to a data construction module if the test parameter configuration is completed; the test parameters comprise transaction core parameters and concurrency numbers in pressure measurement;
when the method of the embodiment of the application is used for testing the performance of the block chain, the test parameters input by a user are received firstly, and the test parameters can be completed by the parameter input module. Specifically, the content included in the test parameters may be determined according to the requirements of the performance test and the actual working needs, and the application is not particularly limited. For example, the test parameters may include an ip internet protocol address of a target machine to be tested, a port, a url webpage address of a specific transaction interface, an interface communication protocol (supporting http hypertext transfer protocol, h2 communication protocol, bolt binary Web service communication protocol, framework of hessian that uses binary Web service protocol, etc.), transaction core parameters and a concurrency number in pressing are set, and according to actual needs, the test parameters may further include cycle number, number of milliseconds for delayed transmission, world state that needs to be uplinked, creation timestamp, transaction version number, and the like. And if the test parameter configuration is completed, triggering a starting instruction to the data construction module.
S2: after receiving a starting instruction, creating threads with the same number as the concurrent number, and constructing respective test data by each thread;
and after the data construction module receives the starting instruction, the data construction module starts to work. Firstly, creating the threads with the same number as the concurrency number specified by a user, wherein each thread is responsible for constructing respective test data, and the test data can comprise transaction core parameters and can be determined according to test requirements and actual conditions.
S3: the thread carries out hash and signature on respective test data, and the hash and signature are preset according to different block chain bottom layers; constructing a complete transaction body according to the test data, the hash and the signature, wherein the complete transaction body is composed of sub transaction bodies of each thread;
after each thread constructs respective test data, each thread hashes and signs the test data, different hash and signature algorithms can be applied according to different block chain bottom layers, and the hashes and signatures can be preset according to different block chain bottom layers. And constructing a complete transaction body according to the test data, the hash and the signature, so far, constructing the complete transaction body. Wherein, the complete transaction body is composed of the respective sub transaction bodies of the threads.
S4: each thread stores the sub transaction bodies in the respective storage space, and after the sub transaction bodies of all threads are constructed, a sending instruction is sent to the data sending module;
each thread can own sub-transaction body, and the sub-transaction bodies of all threads form a complete transaction body. Each thread stores the respective sub-transaction body in a respective storage space, the storage space may be threaded local, the threaded local is a storage class inside the thread, the thread can store data in the designated thread, after the data is stored, only the designated thread can obtain the stored data, and the security level is higher.
It should be noted that the threads are executed out of order, and due to the out-of-order execution of the threads, some sub transaction bodies of the threads are necessarily constructed and completed first, and some sub transaction bodies of the threads are constructed and completed later. In order to prevent out-of-order execution among threads from causing failure in simulating real user concurrency, the embodiment of the present application uses a thread sharing lock to control blocking of each thread, where the thread sharing lock may be CountDownLatch. When all threads complete the transaction body build (data build). CountDownLatch releases, all threads are in a running state at the same time, and the threads are sent to a block chain system to construct a good transaction. That is, as long as there is one thread that does not complete data construction, CountDownLatch does not release, and the thread will release when all the threads complete data construction.
Fig. 2 is a schematic flow chart of controlling blocking of each thread by using the thread sharing lock CountDownLatch according to an embodiment of the present disclosure, and as shown in fig. 2, controlling blocking of each thread by using the thread sharing lock CountDownLatch may include the following steps:
s41: detecting that some threads are executed completely, and sending a pause instruction to the completed threads by using the thread sharing lock;
when the thread sharing lock CountDownLatch is used for controlling the blocking of the threads, the execution of some threads is detected to be finished, a pause instruction is sent to the finished threads by using the thread sharing lock, and at the moment, the threads of the sub-transaction bodies are built first to wait for the threads of the sub-transaction bodies which are not built.
S42: and after the execution of the unfinished thread is finished, canceling the pause instruction to control the blocking of each thread.
And after the execution of the unfinished thread is finished, canceling the pause instruction, namely all the thread sub transaction bodies are built at the moment, and using the pause instruction to enable the thread which is built first to wait for the thread which is not built to control the blockage of each thread so as to avoid the waste of network resources and the like. And after the sub transaction bodies of all the threads are constructed, the data construction module finishes the work and sends a sending instruction to the data sending module.
S5: receiving a sending instruction, distributing the sub-transaction bodies of all threads to the block chain link points corresponding to the threads, and sending a performance acquisition instruction to a performance analysis module;
after receiving the sending instruction, the data sending module distributes the sub transaction bodies of each thread to the blockchain nodes corresponding to the threads, fig. 3 is a schematic flow diagram of distributing the sub transaction bodies of each thread to the blockchain nodes corresponding to the threads according to the embodiment of the present application, and as shown in fig. 3, the specific step of distributing the sub transaction bodies of each thread to the blockchain nodes corresponding to the threads includes:
s51: acquiring the thread number of each thread, and performing modulus calculation according to the thread number of each thread to obtain a modulus result;
and after the data sending module receives the sending instruction, controlling each thread to release the thread sharing lock. After all threads release the thread sharing lock, all threads are in an execution state macroscopically at the moment, and the concurrency number specified by a user is simulated according to the execution state of the threads. Each thread has a respective thread number, and MOD operation (MOD is a mathematical operation symbol, and indicates a modulo operator, for example, a MOD b = c, indicating that the remainder of a divided by b is c) is performed, i.e., modulo calculation, according to the respective thread number of each thread, so as to obtain a modulo result.
S52: and distributing the sub transaction bodies to the block chain nodes corresponding to the threads according to the modulus taking result.
For example, assuming a blockchain has N nodes, then the result M for thread number mod N, representing the branch transaction held by this thread, is sent to the fourth blockchain node, where 0 represents the first node, and so on. And the data sending module distributes the sub transaction bodies corresponding to the threads to different block chain nodes through modular calculation and sends performance acquisition instructions to the performance analysis module. The branch transaction bodies corresponding to the threads are distributed to different blockchain nodes, so that the actual application scenes of the blockchain are better fitted, and the scenes of simultaneously chaining multiple nodes can be quickly simulated.
And after the performance analysis module receives the performance acquisition instruction, the following tasks are executed at the first time.
Task one: s6: after receiving a performance acquisition instruction, recording a first transaction total amount and a first current time received in a block chain at intervals of a first interval period, and pressing the first transaction total amount and the first current time into a TPS stack; the first transaction total amount comprises the number of confirmed sub-transaction bodies and the number of unconfirmed sub-transaction bodies;
and recording a first transaction total amount and a first current time received in the blockchain at intervals of a first interval period, preferably, the first interval period is 1 second, executing the task once every 1 second, going to the blockchain network to inquire the first transaction total amount received in the network during execution, wherein the first transaction total amount comprises the number of confirmed sub-transaction bodies and the number of unconfirmed sub-transaction bodies, and recording the first current time. For example, the first current time may be marked as key1, the first transaction total amount received by the blockchain may be marked as value1, and the first transaction total amount value1 and the first current time key1 are pushed into the TPS stack. When the first transaction total value1 is the same as the first stack top value in the TPS stack, pushing the first transaction total value and the first current time to the TPS stack is stopped. And the first stack top value is the value of the stack top in the TPS stack.
And a second task: s7: recording a second transaction total amount and a second current time received in the block chain every a second interval period, and pressing the second transaction total amount and the second current time into the CTPS stack; the second transaction total amount is the number of the confirmed sub transaction bodies;
and recording a second transaction total amount and a second current time received in the block chain at intervals of a second interval period, preferably, the second interval period is 1 second, executing the tasks once every 1 second, and going to the second transaction total amount in the block chain account book during execution, wherein the second transaction total amount is only the number of confirmed sub-transaction bodies, and recording the second current time. If the second current time may be key2, the second transaction total may be marked as value2, and the second transaction total value2 and the second current time key2 are pushed into the CTPS stack. And when the second transaction total amount is the same as a second stack top value in the CTPS stack, stopping pushing the second transaction total amount and the second current time into the CTPS stack. And the second stack top value is the value of the stack top in the CTPS stack.
S8: and calculating average TPS, average CTPS, real-time TPS and real-time CTPS according to parameters in the TPS stack and the CTPS stack and a preset program.
The mean values and the real-time values of TPS and CTPS need not be calculated manually, and may be calculated logically by tool codes. For example, the embodiment of the application can be developed by using java language, and after the values are calculated by a code program, a user can see the change of the performance index in real time according to a certain display interface.
In one implementation, real-time TPS, real-time CTPS, average TPS, and average CTPS may be calculated by the following ideas and logic. For example, the real-time TPS may be calculated by, for a certain time, dividing a data value difference in a TPS stack by a time key difference to obtain the real-time TPS, where the data value difference is obtained by subtracting two data value values in the TPS stack from each other, and the key difference is obtained by subtracting two times corresponding to the two data values; similarly, the real-time CTPS may be calculated by dividing a data value difference in the CTPS stack by a time key difference at a certain time to obtain the real-time CTPS.
The average TPS may be calculated by dividing (value at the top of the stack minus value at the bottom of the stack) by (value at the top of the stack minus value at the bottom of the stack) in the TPS stack to obtain an average TPS; similarly, the average CTPS may be calculated by dividing (value at the top of the stack minus value at the bottom of the stack) by (value at the top of the stack minus value at the bottom of the stack) in the CTPS stack to obtain the average CTPS. The calculation is calculated through a tool or a code, so that the block chain transaction data is constructed more conveniently, and the hash and the signature change generated by the change of the test data are replaced by the tool/the code, so that the use difficulty of a user is simplified.
To visually represent this link, the following are general performance analysis results:
{
total : 40000,
confirmedTxNum : 40000,
sendTxNum : 40000,
averageTps : 1619,
averageCtps : 1223,
realTimeTps : [
362,
2940,
3731,
88,
183,
2087,
2333,
770,
3475,
477,
3029,
6370,
1666,
665,
3619,
1283,
9909,
565
],
realTimeCtps:[
1015,
884,
2203,
333,
3378,
3441,
5000,
5000,
2503,
1661,
1573
],
txInblockList:[],
maxTps : 9909,
maxCtps : 5000
}
wherein, Total is a Total transaction amount required to be set by a user, confirmedTxNum is a Total number of confirmed transactions in a block chain, sendTxNum is a Total number of transactions sent by a performance tool at the moment, averageTps is an average TPS calculated by the performance tool at the moment, averageCtps is an average CTPS calculated by the performance tool at the moment, realTimtps is a real-time TPS set recorded by the performance tool at the moment, realTimtps is a real-time CTPS set recorded by the performance tool at the moment, maxTPs is a maximum TPS calculated by the performance tool, and maxCTTPS is a maximum CTPS calculated by the performance tool. Compared with the testing tool in the prior art, the block chain of the application pays more attention to the processing speed of transactions, has the capability of monitoring the performance of the block chain transaction uplink, and can more visually display the macroscopic performance expression of the block chain transaction uplink.
According to the technical scheme, the block chain performance testing method comprises the steps of receiving testing parameters input by a user, and triggering a starting instruction to a data construction module if the testing parameters are configured; creating threads with the same number as the concurrent number, and constructing respective test data by each thread; the thread carries out hash and signature on respective test data, and the hash and signature are preset according to different block chain bottom layers; constructing a complete transaction body according to the test data, the hash and the signature; each thread stores the corresponding sub transaction body in the corresponding storage space, the sub transaction bodies of each thread are distributed to the block chain link points corresponding to the thread, and a performance acquisition instruction is sent to the performance analysis module; recording a first transaction total amount and a first current time received in a block chain at intervals of a first interval period, and pressing the first transaction total amount and the first current time into a TPS stack; recording a second transaction total amount and a second current time received in the block chain every a second interval period, and pressing the second transaction total amount and the second current time into the CTPS stack; and calculating average TPS, average CTPS, real-time TPS and real-time CTPS according to parameters in the TPS stack and the CTPS stack and a preset program. Through the application, the test transaction for the performance test can be conveniently constructed, the efficiency of constructing the transaction data body is greatly improved, and two performance indexes of TPS and CTPS can be calculated, monitored and obtained in real time, so that the problems that the transaction data cannot be conveniently constructed and the CTPS cannot be measured by the block chain performance test tool in the prior art are solved.
According to the foregoing embodiments, the present application further provides a device for testing performance of a blockchain, where the device is configured to execute the method for testing performance of a blockchain, fig. 4 is a schematic structural diagram of the device for testing performance of a blockchain provided in the present application, and as shown in fig. 4, the device includes a parameter input module, a data construction module, a data transmission module, and a performance analysis module, where:
the parameter input module is configured to perform the following steps: receiving test parameters input by a user, and triggering a starting instruction to a data construction module if the test parameter configuration is completed; the test parameters comprise transaction core parameters and concurrency numbers in pressure measurement;
the data construction module is configured to perform the steps of: after receiving a starting instruction, creating threads with the same number as the concurrent number, and constructing respective test data by each thread;
the thread carries out hash and signature on respective test data, and the hash and signature are preset according to different block chain bottom layers; constructing a complete transaction body according to the test data, the hash and the signature, wherein the complete transaction body is composed of sub transaction bodies of each thread;
each thread stores the sub transaction bodies in the respective storage space, and after the sub transaction bodies of all threads are constructed, a sending instruction is sent to the data sending module;
the data transmission module is configured to perform the steps of: receiving a sending instruction, distributing the sub-transaction bodies of all threads to the block chain link points corresponding to the threads, and sending a performance acquisition instruction to a performance analysis module;
the performance analysis module is configured to perform the steps of: after receiving a performance acquisition instruction, recording a first transaction total amount and a first current time received in a block chain at intervals of a first interval period, and pressing the first transaction total amount and the first current time into a TPS stack; the first transaction total amount comprises the number of confirmed sub-transaction bodies and the number of unconfirmed sub-transaction bodies;
recording a second transaction total amount and a second current time received in the block chain every a second interval period, and pressing the second transaction total amount and the second current time into the CTPS stack; the second transaction total amount is the number of the confirmed sub transaction bodies;
and calculating average TPS, average CTPS, real-time TPS and real-time CTPS according to parameters in the TPS stack and the CTPS stack and a preset program.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (10)

1. A method for testing performance of a block chain, comprising:
receiving test parameters input by a user, and triggering a starting instruction to a data construction module if the test parameter configuration is completed; the test parameters comprise transaction core parameters and concurrence numbers in pressure measurement;
after the starting instruction is received, threads with the same number as the concurrency number are created, and each thread constructs respective test data;
the thread carries out hash and signature on the respective test data, and the hash and the signature are preset according to different block chain bottom layers; constructing a complete transaction body according to the test data, the hash and the signature, wherein the complete transaction body is composed of sub transaction bodies of the threads;
each thread stores the corresponding sub transaction body in the corresponding storage space, and after the sub transaction bodies of all threads are built, a sending instruction is sent to the data sending module;
receiving the sending instruction, distributing the sub-transaction bodies of each thread to the block chain link points corresponding to the threads, and sending a performance acquisition instruction to a performance analysis module;
after the performance acquisition instruction is received, recording a first transaction total amount and a first current time received in the block chain every a first interval period, and pressing the first transaction total amount and the first current time into a TPS stack; the first transaction total amount comprises the number of confirmed sub-transaction bodies and the number of unconfirmed sub-transaction bodies;
recording a second transaction total amount and a second current time received in the block chain every a second interval period, and pressing the second transaction total amount and the second current time into a CTPS stack; the second transaction total amount is the number of the confirmed sub transaction bodies;
and calculating average TPS, average CTPS, real-time TPS and real-time CTPS according to the parameters in the TPS stack and the CTPS stack and a preset program.
2. The method of claim 1, further comprising: thread sharing locks are utilized to control blocking of individual threads.
3. The blockchain performance testing method of claim 2, wherein the thread sharing lock is CountDownLatch.
4. The blockchain performance testing method of claim 3, wherein utilizing the thread shared lock CountDownLatch to control blocking of each thread comprises:
detecting that some threads are executed completely, and sending a pause instruction to the completed threads by using the thread sharing lock;
and canceling the pause instruction after the execution of the unfinished thread is finished.
5. The method of claim 2, further comprising:
and controlling each thread to release the thread sharing lock so as to enable all the threads to be in an execution state, and simulating the concurrency number according to the execution state of the threads.
6. The method of claim 1, wherein distributing the transaction entity of each thread to the blockchain node corresponding to the thread comprises:
acquiring the thread number of each thread, and performing modulus calculation according to the thread number of each thread to obtain a modulus result;
and distributing the sub transaction bodies to the block chain nodes corresponding to the threads according to the modulus taking result.
7. The method of claim 1, further comprising: when the first transaction total amount is the same as a first stack top value in the TPS stack, stopping pushing the first transaction total amount and the first current time into the TPS stack;
and when the second transaction total amount is the same as a second stack top value in the CTPS stack, stopping pushing the second transaction total amount and the second current time into the CTPS stack.
8. The blockchain performance testing method of claim 1, wherein the threads are executed out-of-order.
9. The blockchain performance testing method of claim 1, wherein the storage space is threaded local, and the threaded local is a storage class inside a thread.
10. A blockchain performance testing apparatus, the apparatus being configured to perform a blockchain performance testing method according to any one of claims 1 to 9, the apparatus comprising a parameter input module, a data construction module, a data transmission module, and a performance analysis module, wherein:
the parameter input module is configured to perform the following steps: receiving test parameters input by a user, and triggering a starting instruction to the data construction module if the test parameter configuration is completed; the test parameters comprise transaction core parameters and concurrence numbers in pressure measurement;
the data construction module is configured to perform the steps of:
after the starting instruction is received, threads with the same number as the concurrency number are created, and each thread constructs respective test data;
the thread carries out hash and signature on the respective test data, and the hash and the signature are preset according to different block chain bottom layers;
constructing a complete transaction body according to the test data, the hash and the signature, wherein the complete transaction body is composed of sub transaction bodies of the threads;
each thread stores the corresponding sub transaction body in the corresponding storage space, and after the sub transaction bodies of all threads are built, a sending instruction is sent to the data sending module;
the data transmission module is configured to perform the steps of: receiving the sending instruction, distributing the sub-transaction bodies of each thread to the block chain link points corresponding to the threads, and sending a performance acquisition instruction to a performance analysis module;
the performance analysis module is configured to perform the steps of:
after the performance acquisition instruction is received, recording a first transaction total amount and a first current time received in the block chain every a first interval period, and pressing the first transaction total amount and the first current time into a TPS stack; the first transaction total amount comprises the number of confirmed sub-transaction bodies and the number of unconfirmed sub-transaction bodies;
recording a second transaction total amount and a second current time received in the block chain every a second interval period, and pressing the second transaction total amount and the second current time into a CTPS stack; the second transaction total amount is the number of the confirmed sub transaction bodies;
and calculating average TPS, average CTPS, real-time TPS and real-time CTPS according to the parameters in the TPS stack and the CTPS stack and a preset program.
CN202111389088.7A 2021-11-23 2021-11-23 Block chain performance test method and device Active CN113821426B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111389088.7A CN113821426B (en) 2021-11-23 2021-11-23 Block chain performance test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111389088.7A CN113821426B (en) 2021-11-23 2021-11-23 Block chain performance test method and device

Publications (2)

Publication Number Publication Date
CN113821426A CN113821426A (en) 2021-12-21
CN113821426B true CN113821426B (en) 2022-02-15

Family

ID=78918060

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111389088.7A Active CN113821426B (en) 2021-11-23 2021-11-23 Block chain performance test method and device

Country Status (1)

Country Link
CN (1) CN113821426B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110061889A (en) * 2019-04-01 2019-07-26 北京众享比特科技有限公司 Block chain performance test methods, device, equipment and storage medium
CN112015628A (en) * 2020-09-01 2020-12-01 北京物资学院 Intelligent contract function level dynamic monitoring and analyzing system and implementation method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113454597A (en) * 2020-09-28 2021-09-28 支付宝(杭州)信息技术有限公司 Block chain transaction processing system and method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110061889A (en) * 2019-04-01 2019-07-26 北京众享比特科技有限公司 Block chain performance test methods, device, equipment and storage medium
CN112015628A (en) * 2020-09-01 2020-12-01 北京物资学院 Intelligent contract function level dynamic monitoring and analyzing system and implementation method

Also Published As

Publication number Publication date
CN113821426A (en) 2021-12-21

Similar Documents

Publication Publication Date Title
CN106470133B (en) System pressure testing method and device
CN104796240B (en) A kind of fuzz testing system of stateful procotol
CN106874159A (en) A kind of concentrating type automated testing method
CN111782524B (en) Application testing method and device, storage medium and electronic device
CN110752969A (en) Performance detection method, device, equipment and medium
CN111008105A (en) Distributed system call relation visualization method and device
CN112988608A (en) Data testing method and device, computer equipment and storage medium
CN109657475A (en) Code vulnerabilities check method, apparatus, equipment and storage medium
CN110489317A (en) Cloud system task run method for diagnosing faults and system based on workflow
CN116719664A (en) Application and cloud platform cross-layer fault analysis method and system based on micro-service deployment
JP2018060332A (en) Incident analysis program, incident analysis method, information processing device, service specification program, service specification method and service specification device
CN113821426B (en) Block chain performance test method and device
CN112202647B (en) Test method, device and test equipment in block chain network
CN112433908B (en) Method, system, device and medium for determining interval time of detection server
CN114422386A (en) Monitoring method and device for micro-service gateway
CN103368970A (en) Automation security detection method for network target
US9658932B2 (en) Lightweight functional testing
Fan et al. Model based Byzantine fault detection technique for cloud computing
CN117234916A (en) Workflow application testing method and device, electronic equipment and storage medium
CN111722917A (en) Resource scheduling method, device and equipment for performance test task
EP3062228A1 (en) Lightweight functional testing
CN114416415A (en) Remote online fault detection method and system for Hongmon operating system and storage medium
CN111611132B (en) Operation and maintenance analysis method, device, equipment and medium for service
CN113360363A (en) Test method, device, equipment and computer storage medium for micro service system
CN112532713A (en) Block chain anti-bifurcation detection method and device

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