This commit is contained in:
rusefillc 2023-10-06 21:17:18 -04:00
parent a65745f07b
commit b871f745a6
2 changed files with 24 additions and 12 deletions

View File

@ -22,22 +22,30 @@ public class ByteRateOfChange {
}
private static void writeByteReport(String reportDestinationFolder, String simpleFileName, TraceFileMetaIndex traceFileMetaIndex) throws FileNotFoundException {
String byteChangesFolder = reportDestinationFolder + File.separator + "byte_changes";
new File(byteChangesFolder).mkdirs();
List<ByteStatistics> allStats = new ArrayList<>(traceFileMetaIndex.statistics.values());
allStats.sort((o1, o2) -> o2.getUniqueValues() - o1.getUniqueValues());
allStats.sort((o1, o2) -> o2.getUniqueValuesCount() - o1.getUniqueValuesCount());
// System.out.println(allStats);
writeByteReport(allStats, byteChangesFolder + File.separator + simpleFileName + "byte_rate_of_changes_sorted_counter.txt");
writeByteReport(reportDestinationFolder, simpleFileName, allStats);
allStats.sort(new Comparator<ByteStatistics>() {
@Override
public int compare(ByteStatistics o1, ByteStatistics o2) {
return o1.key.compareTo(o2.key);
}
});
writeByteReport(allStats, byteChangesFolder + File.separator + simpleFileName + "byte_rate_of_changes_sorted_index.txt");
}
private static void writeByteReport(String reportDestinationFolder, String simpleFileName, List<ByteStatistics> allStats) throws FileNotFoundException {
String outputFileName = reportDestinationFolder + File.separator + simpleFileName + ".txt";
System.out.println("Writing byte report to " + outputFileName);
PrintStream ps = new PrintStream(new FileOutputStream(outputFileName, false));
private static void writeByteReport(List<ByteStatistics> allStats, String fileName) throws FileNotFoundException {
System.out.println("Writing byte report to " + fileName);
PrintStream ps = new PrintStream(new FileOutputStream(fileName, false));
for (ByteStatistics byteStatistics : allStats) {
ByteId key = byteStatistics.key;
ps.println(dualSid(key.sid) + " byte " + key.index + " has " + byteStatistics.getUniqueValues() + " unique value(s)");
ps.println(dualSid(key.sid) + " byte " + key.index + " has " + byteStatistics.getUniqueValuesCount() + " unique value(s)");
}
ps.close();
@ -77,10 +85,14 @@ public class ByteRateOfChange {
this.key = key;
}
public int getUniqueValues() {
public int getUniqueValuesCount() {
return uniqueValues.size();
}
public ByteId getKey() {
return key;
}
@Override
public String toString() {
return "ByteStatistics{" +

View File

@ -40,9 +40,9 @@ public class ByteRateOfChangeReports {
ByteRateOfChange.ByteStatistics s1 = traceReport1.getStatistics().computeIfAbsent(id, ByteRateOfChange.ByteStatistics::new);
ByteRateOfChange.ByteStatistics s2 = traceReport2.getStatistics().computeIfAbsent(id, ByteRateOfChange.ByteStatistics::new);
if (s1.getUniqueValues() != s2.getUniqueValues()) {
String msg = id + ": " + s1.getUniqueValues() + " vs " + s2.getUniqueValues();
int deltaCount = Math.abs(s1.getUniqueValues() - s2.getUniqueValues());
if (s1.getUniqueValuesCount() != s2.getUniqueValuesCount()) {
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);
}