Search in sources :

Example 1 with LatencyStatErr

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++;
        }
    }
}
Also used : ArrayHistory(com.exalttech.trex.util.ArrayHistory) HeaderCell(com.exalttech.trex.ui.views.statistics.cells.HeaderCell) StatisticLabelCell(com.exalttech.trex.ui.views.statistics.cells.StatisticLabelCell) LatencyStat(com.cisco.trex.stateless.model.stats.LatencyStat) FlowStatPoint(com.exalttech.trex.ui.models.stats.FlowStatPoint) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint) PGIDStatsStorage(com.exalttech.trex.ui.views.storages.PGIDStatsStorage) HashMap(java.util.HashMap) Map(java.util.Map) LatencyStatErr(com.cisco.trex.stateless.model.stats.LatencyStatErr) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint)

Aggregations

LatencyStat (com.cisco.trex.stateless.model.stats.LatencyStat)1 LatencyStatErr (com.cisco.trex.stateless.model.stats.LatencyStatErr)1 FlowStatPoint (com.exalttech.trex.ui.models.stats.FlowStatPoint)1 LatencyStatPoint (com.exalttech.trex.ui.models.stats.LatencyStatPoint)1 HeaderCell (com.exalttech.trex.ui.views.statistics.cells.HeaderCell)1 StatisticLabelCell (com.exalttech.trex.ui.views.statistics.cells.StatisticLabelCell)1 PGIDStatsStorage (com.exalttech.trex.ui.views.storages.PGIDStatsStorage)1 ArrayHistory (com.exalttech.trex.util.ArrayHistory)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1