Compare commits

...

2 Commits

Author SHA1 Message Date
rusefillc 82d24ccd22 distribution is the new report! 2024-02-12 22:45:35 -05:00
rusefillc f57782c6c8 dead member 2024-02-12 22:45:10 -05:00
3 changed files with 36 additions and 3 deletions

View File

@ -166,13 +166,11 @@ public class ByteRateOfChange {
}
public static class TraceReport extends HashMap<ByteId, ByteStatistics> {
private final List<CANPacket> packets;
private final String simpleFileName;
private final HashMap<ByteId, ByteStatistics> statistics;
private final double durationMs;
public TraceReport(List<CANPacket> packets, String simpleFileName, HashMap<ByteId, ByteStatistics> statistics) {
this.packets = packets;
this.simpleFileName = simpleFileName;
this.statistics = statistics;
this.durationMs = getDurationMs(packets);

View File

@ -110,8 +110,10 @@ public class ByteRateOfChangeReports {
CanToMegaLogViewer.createMegaLogViewer(reportDestinationFolder, logFileContent, simpleFileName);
PacketRatio.write(reportDestinationFolder, logFileContent, simpleFileName);
ByteRateOfChange.TraceReport report = ByteRateOfChange.process(reportDestinationFolder, simpleFileName, logFileContent);
report.save("temp-ByteRateOfChange.txt");
report.save(simpleFileName + "-ByteRateOfChange.txt");
reports.add(report);
}, fileNameSuffix);

View File

@ -0,0 +1,33 @@
package com.rusefi.can.analysis;
import com.rusefi.can.CANPacket;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;
public class PacketRatio {
public static void write(String reportDestinationFolder, List<CANPacket> logFileContent, String simpleFileName) throws IOException {
Map<Integer, AtomicInteger> countBySID = new TreeMap<>();
for (CANPacket packet : logFileContent) {
AtomicInteger counter = countBySID.computeIfAbsent(packet.getId(), integer -> new AtomicInteger());
counter.incrementAndGet();
}
Writer w = new FileWriter(reportDestinationFolder + File.separator + "distribution_" + simpleFileName);
for (Map.Entry<Integer, AtomicInteger> e : countBySID.entrySet()) {
double ratio = 100.0 * e.getValue().get() / logFileContent.size();
w.write(ByteRateOfChange.dualSid(e.getKey()) + ": " + ratio + "\n");
}
w.close();
}
}