total transitions is helpful

This commit is contained in:
rusefillc 2023-10-22 23:37:22 -04:00
parent 58568716da
commit 661d642cd2
2 changed files with 16 additions and 3 deletions

View File

@ -59,7 +59,7 @@ public class ByteRateOfChange {
for (int byteIndex = 0; byteIndex < packet.getData().length; byteIndex++) {
ByteId key = new ByteId(packet.getId(), byteIndex);
ByteStatistics stats = traceFileMetaIndex.statistics.computeIfAbsent(key, byteId -> new ByteStatistics(key));
stats.uniqueValues.add((int) packet.getData()[byteIndex]);
stats.registerValue(packet.getData()[byteIndex]);
}
}
return traceFileMetaIndex;
@ -78,9 +78,12 @@ public class ByteRateOfChange {
}
public static class ByteStatistics {
HashSet<Integer> uniqueValues = new HashSet<>();
private final HashSet<Integer> uniqueValues = new HashSet<>();
int totalTransitions;
private final ByteId key;
private int previousValue;
public ByteStatistics(ByteId key) {
this.key = key;
}
@ -100,6 +103,16 @@ public class ByteRateOfChange {
", key=" + key +
'}';
}
public void registerValue(int value) {
if (!uniqueValues.isEmpty()) {
if (previousValue != value)
totalTransitions++;
}
previousValue = value;
uniqueValues.add(value);
}
}

View File

@ -53,7 +53,7 @@ public class ByteRateOfChangeReports {
String msg = id + ": " + s1.getUniqueValuesCount() + " vs " + s2.getUniqueValuesCount();
int deltaCount = Math.abs(s1.getUniqueValuesCount() - s2.getUniqueValuesCount());
differences.add(new ByteVariationDifference(deltaCount, msg));
report.println(msg + " delta=" + deltaCount);
report.println(msg + " delta=" + deltaCount + " / " + s1.totalTransitions + " vs " + s2.totalTransitions);
}
}