use of com.cisco.trex.stateless.model.stats.LatencyStatLat in project trex-stateless-gui by cisco-system-traffic-generator.
the class Latency method renderWindow.
private void renderWindow() {
table.getChildren().clear();
int hCol = 0;
table.add(new HeaderCell(FIRST_COLUMN_WIDTH, "PG ID"), 0, hCol++);
table.add(new StatisticLabelCell("Tx pkt", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Rx pkt", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Max Latency", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Avg Latency", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Last (max)", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
for (int i = 0; i < WINDOW_SIZE - 1; ++i) {
table.add(new StatisticLabelCell(String.format("Last-%d", i + 1), FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
}
table.add(new StatisticLabelCell("Jitter", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Errors", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol);
final PGIDStatsStorage pgIDStatsStorage = StatsStorage.getInstance().getPGIDStatsStorage();
final Map<Integer, ArrayHistory<FlowStatPoint>> flowStatPointHistoryMap = pgIDStatsStorage.getFlowStatPointHistoryMap();
final Map<Integer, FlowStatPoint> flowStatPointShadowMap = pgIDStatsStorage.getFlowStatPointShadowMap();
final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap = pgIDStatsStorage.getLatencyStatPointHistoryMap();
final Map<Integer, LatencyStatPoint> latencyStatPointShadowMap = pgIDStatsStorage.getLatencyStatPointShadowMap();
int rowIndex = 1;
synchronized (pgIDStatsStorage.getFlowLock()) {
synchronized (pgIDStatsStorage.getLatencyLock()) {
for (final Map.Entry<Integer, ArrayHistory<FlowStatPoint>> entry : flowStatPointHistoryMap.entrySet()) {
final int pgID = entry.getKey();
final ArrayHistory<FlowStatPoint> flowHistory = entry.getValue();
if (flowHistory == null || flowHistory.isEmpty()) {
continue;
}
final FlowStatPoint flowStatPoint = flowHistory.last();
final ArrayHistory<LatencyStatPoint> latencyHistory = latencyStatPointHistoryMap.get(pgID);
if (latencyHistory == null || latencyHistory.isEmpty()) {
continue;
}
final LatencyStat latencyStat = latencyHistory.last().getLatencyStat();
final long[] window = new long[WINDOW_SIZE];
for (int i = 0; i < WINDOW_SIZE; ++i) {
window[i] = 0;
}
final int latencyHistorySize = latencyHistory.size();
final int size = Math.min(latencyHistorySize, WINDOW_SIZE);
for (int i = 0; i < size; i++) {
window[i] = latencyHistory.get(latencyHistorySize - 1 - i).getLatencyStat().getLat().getLastMax();
}
long tp = flowStatPoint.getTp();
long rp = flowStatPoint.getRp();
final FlowStatPoint flowShadow = flowStatPointShadowMap.get(pgID);
if (flowShadow != null) {
tp -= flowShadow.getTp();
rp -= flowShadow.getRp();
}
long totalErr = latencyStat.getErr().getTotal();
final LatencyStatPoint latencyShadow = latencyStatPointShadowMap.get(pgID);
if (latencyShadow != null) {
totalErr -= latencyShadow.getLatencyStat().getErr().getTotal();
}
final LatencyStatLat lat = latencyStat.getLat();
int col = 0;
table.add(new HeaderCell(COLUMN_WIDTH, String.valueOf(pgID)), rowIndex, col++);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(tp), true, "pkts"), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(rp), true, "pkts"), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.format("%d µs", lat.getTotalMax()), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.format(Locale.US, "%.2f µs", round(lat.getAverage())), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
for (int i = 0; i < WINDOW_SIZE; ++i) {
table.add(new StatisticLabelCell(String.valueOf(window[i]), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
}
table.add(new StatisticLabelCell(String.format("%d µs", lat.getJit()), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.valueOf(totalErr), COLUMN_WIDTH, true, CellType.ERROR_CELL, true), rowIndex, col++);
rowIndex++;
}
}
}
}
Aggregations