counter report as yaml
This commit is contained in:
parent
1a23e50ed0
commit
2059134948
|
@ -45,7 +45,7 @@ public class ByteRateOfChange {
|
|||
|
||||
for (ByteStatistics byteStatistics : allStats) {
|
||||
ByteId key = byteStatistics.key;
|
||||
ps.println(dualSid(key.sid) + " byte " + key.index + " has " + byteStatistics.getUniqueValuesCount() + " unique value(s)");
|
||||
ps.println(dualSid(key.sid) + " byte " + key.bitIndex + " has " + byteStatistics.getUniqueValuesCount() + " unique value(s)");
|
||||
}
|
||||
|
||||
ps.close();
|
||||
|
@ -105,15 +105,15 @@ public class ByteRateOfChange {
|
|||
|
||||
public static class ByteId implements Comparable<ByteId> {
|
||||
final int sid;
|
||||
final int index;
|
||||
final int bitIndex;
|
||||
|
||||
public ByteId(int sid, int index) {
|
||||
public ByteId(int sid, int bitIndex) {
|
||||
this.sid = sid;
|
||||
this.index = index;
|
||||
this.bitIndex = bitIndex;
|
||||
}
|
||||
|
||||
public String getLogKey() {
|
||||
return dualSid(sid) + "_byte_" + index + "_bit_" + (index * 8);
|
||||
return dualSid(sid) + "_byte_" + bitIndex + "_bit_" + (bitIndex * 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,20 +121,20 @@ public class ByteRateOfChange {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ByteId byteId = (ByteId) o;
|
||||
return sid == byteId.sid && index == byteId.index;
|
||||
return sid == byteId.sid && bitIndex == byteId.bitIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(sid, index);
|
||||
return Objects.hash(sid, bitIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ByteId o) {
|
||||
ByteId other = (ByteId) o;
|
||||
ByteId other = o;
|
||||
if (other.sid != sid)
|
||||
return sid - other.sid;
|
||||
return index - other.index;
|
||||
return bitIndex - other.bitIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,6 +64,14 @@ public class CounterAggregator {
|
|||
this.totalNumberOfBits = totalNumberOfBits;
|
||||
}
|
||||
|
||||
public CounterScanner.BitStateKey getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public int getTotalNumberOfBits() {
|
||||
return totalNumberOfBits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Counter{" +
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.rusefi.can.analysis;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class CounterScanner {
|
||||
public static void scanForCounters(String reportDestinationFolder, List<CANPacket> packets) throws FileNotFoundException {
|
||||
public static void scanForCounters(String reportDestinationFolder, List<CANPacket> packets) throws IOException {
|
||||
|
||||
String outputFileName = reportDestinationFolder + File.separator + "counter_report.txt";
|
||||
PrintWriter pw = new PrintWriter(new FileOutputStream(outputFileName));
|
||||
|
@ -47,10 +48,20 @@ public class CounterScanner {
|
|||
pw.println("Scanning...");
|
||||
List<CounterAggregator.CounterWithWidth> countersWithWidth = CounterAggregator.scan(counters);
|
||||
|
||||
Yaml yaml = new Yaml();
|
||||
Map<Integer, Map<Integer, Integer>> map = new HashMap<>();
|
||||
|
||||
pw.println("Here are the founding:");
|
||||
for (CounterAggregator.CounterWithWidth counterWithWidth : countersWithWidth) {
|
||||
pw.println("Found " + counterWithWidth);
|
||||
|
||||
Map<Integer, Integer> lengthByStartIndex = map.computeIfAbsent(counterWithWidth.getStart().getSid(), integer -> new HashMap<>());
|
||||
|
||||
lengthByStartIndex.put(counterWithWidth.getStart().getTotalBitIndex(), counterWithWidth.getTotalNumberOfBits());
|
||||
}
|
||||
String yamlCountersReportFileName = reportDestinationFolder + File.separator + "counters.yaml";
|
||||
System.out.println("Writing report to " + yamlCountersReportFileName);
|
||||
yaml.dump(map, new FileWriter(yamlCountersReportFileName));
|
||||
pw.close();
|
||||
}
|
||||
|
||||
|
@ -63,12 +74,16 @@ public class CounterScanner {
|
|||
this.bitIndex = bitIndex;
|
||||
}
|
||||
|
||||
public int getTotalBitIndex() {
|
||||
return byteId.bitIndex * 8 + bitIndex;
|
||||
}
|
||||
|
||||
public int getSid() {
|
||||
return byteId.sid;
|
||||
}
|
||||
|
||||
public int getByteIndex() {
|
||||
return byteId.index;
|
||||
return byteId.bitIndex;
|
||||
}
|
||||
|
||||
public int getBitIndex() {
|
||||
|
|
Loading…
Reference in New Issue