package org.fisco.bcos.channel.test.parallel.parallelok;
import java.math.BigInteger;
import org.fisco.bcos.web3j.crypto.EncryptType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PerformanceDT {
// 日志类
private static Logger logger = LoggerFactory.getLogger(PerformanceDT.class);
// 命令用法
public static void Usage() {
System.out.println(" Usage:");
// 添加测试用户
System.out.println(
" \t java -cp conf/:lib/*:apps/* org.fisco.bcos.channel.test.parallel.parallelok.PerformanceDT groupID add count tps file.");
// 转账测试
// java -cp conf/:lib/*:apps/* org.fisco.bcos.channel.test.parallel.parallelok.PerformanceDT 1 transfer 100000 4000 user 2
System.out.println(
" \t java -cp conf/:lib/*:apps/* org.fisco.bcos.channel.test.parallel.parallelok.PerformanceDT groupID transfer count tps file strategy queryAccountQPS.");
//
System.out.println(
" \t java -cp conf/:lib/*:apps/* org.fisco.bcos.channel.test.parallel.parallelok.PerformanceDT groupID transferRevert count tps file strategy queryAccountQPS.");
System.exit(0);
}
public static void main(String[] args) throws Exception {
// 参数的个数必须大于等于4
if (args.length < 4) {
Usage();
}
// 群组id
String groupID = args[0];
// 命令
String command = args[1];
// 要发送的tps总数
BigInteger count = new BigInteger(args[2]);
// 客户端以多少的TPS发送
BigInteger tps = new BigInteger(args[3]);
// 保存user的文件
String file = null;
// 发送的交易间有20%的互斥
BigInteger deci = new BigInteger("0");
BigInteger queryAccountQPS = tps;
if (args.length > 4) {
file = args[4];
if (args.length > 5) {
deci = new BigInteger(args[5]);
}
if (args.length > 6) {
queryAccountQPS = new BigInteger(args[6]);
}
}
// deci can not bigger than 10.
if (deci.compareTo(new BigInteger("10")) > 0) {
deci = new BigInteger("10");
}
// 日志
logger.info(
" dag transfer test begin, command is {}, count is {}, tps is {}, file is {}, deci is {}, queryAccountQPS is {}",
command,
count,
tps,
file,
deci,
queryAccountQPS);
// 用户集的文件
DagUserMgr d = new DagUserMgr();
d.setFile(file);
// 收集器
PerformanceDTCollector collector = new PerformanceDTCollector();
// 设置要发送的tps总数
collector.setTotal(count.intValue());
// 设置用户集
collector.setDagUserMrg(d);
// 要测试的节点集
PerformanceDTTest PerformanceDTTest = new PerformanceDTTest(groupID);
// 绑定收集器
PerformanceDTTest.setCollector(collector);
// 绑定用户集
PerformanceDTTest.setDagUserMgr(d);
collector.setPerformanceDTTest(PerformanceDTTest);
// 普通还是国密
System.out.println(
(EncryptType.encryptType == EncryptType.ECDSA_TYPE)
? " ===>> normal parallel "
: " ===>> gm parallel ");
// 根据不同的命令调用不同的函数
switch (command) {
case "add":
// 设置测试类型
d.setTestType("add");
// 新增用户
PerformanceDTTest.userAddTest(count, tps);
break;
case "transfer":
d.setTestType("transfer");
d.loadDagTransferUser();
PerformanceDTTest.userTransferTest(count, tps, deci, queryAccountQPS);
break;
case "transferRevert":
d.setTestType("transferRevert");
d.loadDagTransferUser();
PerformanceDTTest.userTransferRevertTest(count, tps, deci, queryAccountQPS);
default:
Usage();
}
}
}