Jashinck commented on code in PR #131:
URL: 
https://github.com/apache/rocketmq-eventbridge/pull/131#discussion_r1251603262


##########
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指标,只记录过去一秒内完成从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]

Reply via email to