MCPcopy Create free account
hub / github.com/e2wugui/zeze / PerfCounter

Class PerfCounter

ZezeJava/ZezeJava/src/main/java/Zeze/Util/PerfCounter.java:21–801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19import org.jetbrains.annotations.Nullable;
20
21public final class PerfCounter extends FastLock implements ZezeCounter {
22 public static class LongAdderCounter extends LongAdder implements LongCounter {
23 @Override
24 public void inc(long v) {
25 add(v);
26 }
27 }
28
29 private static final LongObserver dummyLongObserver = v -> {
30 };
31
32 private static class RunInfo {
33 static final int MAX_IDLE_COUNT = 10; // 最多几轮没有收集到信息就自动清除该条目
34
35 final @NotNull String name;
36 final LongAdder procCount = new LongAdder(); // 处理次数
37 final LongAdder procTime = new LongAdder(); // 处理时间(ns)
38 long lastProcCount;
39 long lastProcTime;
40 int idleCount; // 没收集到信息的轮数
41
42 RunInfo(@NotNull String name) {
43 this.name = name;
44 }
45 }
46
47 private static final class RunInfoWithSerial extends RunInfo {
48 final int serial;
49
50 RunInfoWithSerial(@NotNull String name, int serial) {
51 super(name);
52 this.serial = serial;
53 }
54 }
55
56 private static final class ProtocolInfo extends RunInfo {
57 final LongAdder recvSize = new LongAdder(); // 接收字节
58 final LongAdder sendCount = new LongAdder(); // 发送次数
59 final LongAdder sendSize = new LongAdder(); // 发送字节
60 long lastRecvSize;
61 long lastSendCount;
62 long lastSendSize;
63
64 ProtocolInfo(String name) {
65 super(name);
66 }
67 }
68
69 /**
70 * 在Procedure中统计,由于嵌套存储过程存在,总数会比实际事务数多。
71 * 一般嵌套存储过程很少用,事务数量也可以参考这里的数值,不单独统计。
72 * 另外Transaction在重做时会在这里保存重做次数的统计。通过name和存储过程区分开来。
73 */
74 public static final class ProcedureInfo {
75 static final int MAX_IDLE_COUNT = 10; // 最多几轮没有收集到信息就自动清除该条目
76
77 final @NotNull String name;
78 @NotNull LongConcurrentHashMap<LongAdder> resultMap = new LongConcurrentHashMap<>();

Callers

nothing calls this directly

Calls 6

setAccessibleMethod · 0.95
allocCounterMethod · 0.95
parseIntMethod · 0.80
getPropertyMethod · 0.80
getDeclaredFieldMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected