Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tools/stress_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ statistic = {
- `startBlockNumber`: configure the start block number of range for the TPS statistic;
- `endBlockNumber`: configure the end block number of range for the TPS statistic;

*Note*: if the `url` points to Lite full node, you should make sure
its configuration `openHistoryQueryWhenLiteFN = true` is set.

Then we can execute the `statistic` subcommand.
```
# execute full command
Expand Down
1 change: 1 addition & 0 deletions tools/stress_test/src/main/java/org/tron/BroadcastTx.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public Integer call() throws IOException, InterruptedException, IllegalException
}
Args.getInstance().setNodeListenPort(nodeListenPort);
logger.info("rpc.port: {}, node.listen.port {}", rpcPort, nodeListenPort);
Args.getInstance().setOpenHistoryQueryWhenLiteFN(true);

context = new TronApplicationContext(DefaultConfig.class);
app = ApplicationFactory.create(context);
Expand Down
2 changes: 2 additions & 0 deletions tools/stress_test/src/main/java/org/tron/TpsStatistic.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public Integer call() throws Exception {
Statistic.setApiWrapper(
new ApiWrapper(config.getStatisticUrl(), config.getStatisticUrl(),
config.getPrivateKey()));
Statistic.setBroadcastTpsLimit(config.getBroadcastTpsLimit());
Statistic.setTotalGenerateTxCnt(config.getTotalTxCnt());
Statistic.result(startBlock, endBlock, output);
return 0;
}
Expand Down
15 changes: 11 additions & 4 deletions tools/stress_test/src/main/java/org/tron/utils/Statistic.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public static void result(long startBlock, long endBlock, String output) throws
int minTrxCntInOneBlock = 1000000;
int trxCnt = 0;
int totalTrxCnt = 0;
int minBlockNumber = 0;
int maxBlockNumber = 0;

for (long i = startNumber; i < endNumber; i++) {
block = apiWrapper.getBlockByNum(i);
Expand All @@ -61,9 +63,11 @@ public static void result(long startBlock, long endBlock, String output) throws

if (trxCnt > maxTrxCntInOneBlock) {
maxTrxCntInOneBlock = trxCnt;
maxBlockNumber = (int) i;
}
if (trxCnt < minTrxCntInOneBlock) {
minTrxCntInOneBlock = trxCnt;
minBlockNumber = (int) i;
}
}

Expand All @@ -83,8 +87,8 @@ public static void result(long startBlock, long endBlock, String output) throws
logger.info("total generate tx count: {}, total broadcast tx count: {}, tx on chain rate: {}",
totalGenerateTxCnt, totalTrxCnt, 1.0 * totalTrxCnt / totalGenerateTxCnt);
logger.info("cost time: {} minutes", 1.0 * actualTime / (60 * 1000));
logger.info("max block size: {}", maxTrxCntInOneBlock);
logger.info("min block size: {}", minTrxCntInOneBlock);
logger.info("max block size: {} in block: {}", maxTrxCntInOneBlock, maxBlockNumber);
logger.info("min block size: {} in block: {}", minTrxCntInOneBlock, minBlockNumber);
logger.info("tps: {}", tps);
logger.info("miss block rate: {}", missBlockRate);

Expand All @@ -102,13 +106,16 @@ public static void result(long startBlock, long endBlock, String output) throws
writer.newLine();
writer.write(String.format("cost time: %f minutes", 1.0 * actualTime / (60 * 1000)));
writer.newLine();
writer.write(String.format("max block size: %d", maxTrxCntInOneBlock));
writer.write(
String.format("max block size: %d in block: %d", maxTrxCntInOneBlock, maxBlockNumber));
writer.newLine();
writer.write(String.format("min block size: %d", minTrxCntInOneBlock));
writer.write(
String.format("min block size: %d in block: %d", minTrxCntInOneBlock, minBlockNumber));
writer.newLine();
writer.write(String.format("tps: %f", tps));
writer.newLine();
writer.write(String.format("miss block rate: %f", missBlockRate));
writer.newLine();
} catch (IOException e) {
e.printStackTrace();
}
Expand Down