[fix](profile) fix simply profile because counter may be not same

This commit is contained in:
Mryange
2023-09-15 21:11:01 +08:00
committed by GitHub
parent b407f275c8
commit 5b43969e35
2 changed files with 19 additions and 8 deletions

View File

@ -51,6 +51,9 @@ public class Counter {
}
public void addValue(Counter other) {
if (other == null) {
return;
}
this.value += other.value;
}

View File

@ -374,7 +374,6 @@ public class RuntimeProfile {
counter.addValue(othCounter);
}
}
counter.setValue(0); // Because the time is not accurate, it has been set to 0.
}
private static void removePipelineContext(RuntimeProfile src) {
@ -432,6 +431,9 @@ public class RuntimeProfile {
private static void mergeCounter(RuntimeProfile src, String counterName, Counter counter,
LinkedList<Counter> rhsCounter) {
if (rhsCounter == null) {
return;
}
if (rhsCounter.size() == 0) {
return;
}
@ -439,15 +441,19 @@ public class RuntimeProfile {
Counter maxCounter = new Counter(counter.getType(), counter.getValue());
Counter minCounter = new Counter(counter.getType(), counter.getValue());
for (Counter cnt : rhsCounter) {
if (cnt.getValue() > maxCounter.getValue()) {
maxCounter.setValue(cnt.getValue());
}
if (cnt.getValue() < minCounter.getValue()) {
minCounter.setValue(cnt.getValue());
if (cnt != null) {
if (cnt.getValue() > maxCounter.getValue()) {
maxCounter.setValue(cnt.getValue());
}
if (cnt.getValue() < minCounter.getValue()) {
minCounter.setValue(cnt.getValue());
}
}
}
for (Counter cnt : rhsCounter) {
counter.addValue(cnt);
if (cnt != null) {
counter.addValue(cnt);
}
}
long countNumber = rhsCounter.size() + 1;
counter.divValue(countNumber);
@ -476,7 +482,9 @@ public class RuntimeProfile {
return;
}
for (Counter cnt : rhsCounter) {
counter.addValue(cnt);
if (cnt != null) {
counter.addValue(cnt);
}
}
}
}