lkmxsxd commented on code in PR #131:
URL:
https://github.com/apache/rocketmq-eventbridge/pull/131#discussion_r1251628645
##########
adapter/benchmark/src/main/java/org/apache/rocketmq/eventbridge/adapter/benchmark/AbstractEventCommon.java:
##########
@@ -100,27 +91,42 @@ protected String twoDecimal(double doubleValue) {
}
protected void printStats() {
- if (snapshotList.size() >= 10) {
- Long[] begin = snapshotList.getFirst();
- Long[] end = snapshotList.getLast();
+ if (snapshotList.size() < 1) return;
+ if (snapshotList.size() > 3) {
+ snapshotList.removeFirst();
+ }
+ Long[] end = snapshotList.getLast();
- final long tps = (long) (((end[1] - begin[1]) / (double) (end[0] -
begin[0])) * 1000L);
- final long failCount = end[2] - begin[2];
+ // tps: 每秒钟能处理的消息数; 消息总数/消耗时长
+ final long tps = (long) (end[3] / (double) end[0] * 1000L);
- // 处理的消息条数
- long c = end[3] - begin[3];
- c = c <= 0 ? 1 : c;
- // 时间
- long t = end[0] - begin[0];
- // 条/ms
- final long delayTime = t / c;
+ final long failCount = end[2];
- String sysState = getSystemState();
+ // 消息总数
+ double c = (double) end[3];
+ c = c <= 0 ? 1 : c;
+ // 消耗时长
+ double t = (double) (end[0]);
+ // 条/ms
+ final double delayTime = t / c;
+ String delayTimeStr = twoDecimal(delayTime);
- String info = String.format("Current Time: %s | TPS: %d |
delayTime: %d | Consume Fail: %d | %s",
-
UtilAll.timeMillisToHumanString2(System.currentTimeMillis()), tps, delayTime,
failCount, sysState);
+ String sysState = getSystemState();
- printStream.println(info);
- }
+ String info = String.format("Current Time: %s | TPS: %d |
delayTime: %sms | Consume Fail: %d | %s",
+ UtilAll.timeMillisToHumanString2(System.currentTimeMillis()),
tps, delayTimeStr, failCount, sysState);
+
+ printStream.println(info);
+ }
+
+ public void successCount(int batchSize, long costTime) {
+ statsBenchmarkCommon.getSuccessCount().increment();
+ statsBenchmarkCommon.getRecordCount().add(batchSize);
+ statsBenchmarkCommon.getCostTime().add(costTime);
Review Comment:
> costTime累加不合理,在Trigger中是线程池处理的,很大概率存在拉取的消息并发处理的
costTime累计的是消息从接受到Listener 到Trigger处理完成的过程时间,记录的是与并发处理结束后的时间差
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]