use of com.cisco.trex.stateless.model.stats.LatencyStatErr in project trex-stateless-gui by cisco-system-traffic-generator.
the class Latency method renderHistogram.
private void renderHistogram() {
table.getChildren().clear();
final PGIDStatsStorage pgIDStatsStorage = StatsStorage.getInstance().getPGIDStatsStorage();
final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap = pgIDStatsStorage.getLatencyStatPointHistoryMap();
final Map<Integer, LatencyStatPoint> latencyStatPointShadowMap = pgIDStatsStorage.getLatencyStatPointShadowMap();
final String[] histogramKeys = pgIDStatsStorage.getHistogramKeys(HISTOGRAM_SIZE);
int hCol = 0;
table.add(new HeaderCell(FIRST_COLUMN_WIDTH, "PG ID"), 0, hCol++);
for (final String key : histogramKeys) {
table.add(new StatisticLabelCell(key, FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
}
table.add(new StatisticLabelCell("Dropped", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Dup", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Out Of Order", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Seq To High", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Seq To Low", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol);
int rowIndex = 1;
synchronized (pgIDStatsStorage.getLatencyLock()) {
for (final Map.Entry<Integer, ArrayHistory<LatencyStatPoint>> entry : latencyStatPointHistoryMap.entrySet()) {
final int pgID = entry.getKey();
final ArrayHistory<LatencyStatPoint> latencyHistory = latencyStatPointHistoryMap.get(pgID);
if (latencyHistory == null || latencyHistory.isEmpty()) {
continue;
}
final LatencyStat latencyStat = latencyHistory.last().getLatencyStat();
final Map<String, Long> histogram = latencyStat.getLat().getHistogram();
final LatencyStatErr latencyStatErr = latencyStat.getErr();
long drp = latencyStatErr.getDrp();
long dup = latencyStatErr.getDup();
long ooo = latencyStatErr.getOoo();
long sth = latencyStatErr.getSth();
long stl = latencyStatErr.getStl();
final LatencyStatPoint latencyShadow = latencyStatPointShadowMap.get(pgID);
Map<String, Long> shadowHistogram;
if (latencyShadow != null) {
final LatencyStatErr latencyStatShadowErr = latencyShadow.getLatencyStat().getErr();
drp -= latencyStatShadowErr.getDrp();
dup -= latencyStatShadowErr.getDup();
ooo -= latencyStatShadowErr.getOoo();
sth -= latencyStatShadowErr.getSth();
stl -= latencyStatShadowErr.getStl();
shadowHistogram = latencyShadow.getLatencyStat().getLat().getHistogram();
} else {
shadowHistogram = new HashMap<>();
}
int col = 0;
table.add(new HeaderCell(COLUMN_WIDTH, String.valueOf(pgID)), rowIndex, col++);
for (final String key : histogramKeys) {
final long value = histogram.getOrDefault(key, 0L);
final long shadowValue = shadowHistogram.getOrDefault(key, 0L);
table.add(new StatisticLabelCell(String.valueOf(value - shadowValue), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
}
table.add(new StatisticLabelCell(String.valueOf(drp), COLUMN_WIDTH, col % 2 == 0, CellType.ERROR_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.valueOf(dup), COLUMN_WIDTH, col % 2 == 0, CellType.ERROR_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.valueOf(ooo), COLUMN_WIDTH, col % 2 == 0, CellType.ERROR_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.valueOf(sth), COLUMN_WIDTH, col % 2 == 0, CellType.ERROR_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.valueOf(stl), COLUMN_WIDTH, col % 2 == 0, CellType.ERROR_CELL, true), rowIndex, col);
rowIndex++;
}
}
}
Aggregations