File tree Expand file tree Collapse file tree 4 files changed +10
-4
lines changed
main/java/com/wujiuye/flow
test/java/com/wujiuye/flow Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -155,3 +155,9 @@ public class Main{
155155 }
156156}
157157```
158+
159+ ### A&Q
160+
161+ * 1、平均请求数的统计有问题?
162+ 平均请求数的计算:如果统计一分钟的qps,那么平均就是当前成功请求数/60秒。\
163+ 所以要准确的话,前一分钟是准确的,当前分钟是不准确的。
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public SecondFlower() {
1818
1919 @ Override
2020 protected long getWindowInterval (long windowInterval ) {
21- return windowInterval ;
21+ return windowInterval / 1000 ;
2222 }
2323
2424}
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ public interface Metric {
6666 void addRt (long rt );
6767
6868 /**
69- * 获取以耗秒为单位的滑动窗口长度
69+ * 获取以毫秒为单位的滑动窗口长度
7070 */
7171 long getWindowInterval ();
7272
Original file line number Diff line number Diff line change 88public class FlowTest {
99
1010 public static void main (String [] args ) throws InterruptedException {
11- FlowHelper flowHelper = new FlowHelper (FlowType .Minute );
11+ FlowHelper flowHelper = new FlowHelper (FlowType .Second );
1212 new Thread (() -> {
1313 while (!Thread .interrupted ()) {
1414 try {
@@ -21,7 +21,7 @@ public static void main(String[] args) throws InterruptedException {
2121 }).start ();
2222 new Thread (() -> {
2323 while (!Thread .interrupted ()) {
24- Flower flower = flowHelper .getFlow (FlowType .Minute );
24+ Flower flower = flowHelper .getFlow (FlowType .Second );
2525 System .out .println ("总请求数:" + flower .total ());
2626 System .out .println ("成功请求数:" + flower .totalSuccess ());
2727 System .out .println ("异常请求数:" + flower .totalException ());
You can’t perform that action at this time.
0 commit comments