Search in sources :

Example 1 with LatencyStatPoint

use of com.exalttech.trex.ui.models.stats.LatencyStatPoint in project trex-stateless-gui by cisco-system-traffic-generator.

the class LatencyLineChart method render.

@Override
protected void render() {
    getChart().getData().clear();
    final StatsStorage statsStorage = StatsStorage.getInstance();
    final Map<Integer, String> selectedPGIDs = statsStorage.getPGIDsStorage().getSelectedPGIds();
    final PGIDStatsStorage pgIDStatsStorage = statsStorage.getPGIDStatsStorage();
    final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap = pgIDStatsStorage.getLatencyStatPointHistoryMap();
    final List<XYChart.Series<Double, Number>> seriesList = new LinkedList<>();
    synchronized (pgIDStatsStorage.getLatencyLock()) {
        latencyStatPointHistoryMap.forEach((final Integer pgID, final ArrayHistory<LatencyStatPoint> history) -> {
            if (history == null || history.isEmpty()) {
                return;
            }
            final String color = selectedPGIDs.get(pgID);
            if (color == null) {
                return;
            }
            final double lastTime = history.last().getTime();
            final XYChart.Series<Double, Number> series = new XYChart.Series<>();
            series.setName(String.valueOf(pgID));
            int size = history.size();
            for (int i = 0; i < size; ++i) {
                final LatencyStatPoint point = history.get(i);
                final double time = point.getTime();
                series.getData().add(new XYChart.Data<>(time - lastTime, getValue(point)));
            }
            setSeriesColor(series, color);
            seriesList.add(series);
        });
    }
    getChart().getData().addAll(seriesList);
}
Also used : ArrayHistory(com.exalttech.trex.util.ArrayHistory) PGIDStatsStorage(com.exalttech.trex.ui.views.storages.PGIDStatsStorage) StatsStorage(com.exalttech.trex.ui.views.storages.StatsStorage) LinkedList(java.util.LinkedList) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint) PGIDStatsStorage(com.exalttech.trex.ui.views.storages.PGIDStatsStorage) XYChart(javafx.scene.chart.XYChart) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint)

Example 2 with LatencyStatPoint

use of com.exalttech.trex.ui.models.stats.LatencyStatPoint in project trex-stateless-gui by cisco-system-traffic-generator.

the class PGIDStatsStorage method processLatencyStats.

private void processLatencyStats(final Map<String, LatencyStat> latencyStatMap, final double time) {
    synchronized (latencyLock) {
        final Set<Integer> unvisitedStreams = new HashSet<>(latencyStatPointHistoryMap.keySet());
        final Set<String> histogramKeysSet = new HashSet<>();
        latencyStatMap.forEach((final String pgID, final LatencyStat latencyStat) -> {
            int intPGID;
            try {
                intPGID = Integer.valueOf(pgID);
            } catch (NumberFormatException exc) {
                return;
            }
            unvisitedStreams.remove(intPGID);
            final LatencyStatPoint statsFlowHistoryPoint = new LatencyStatPoint(latencyStat, time);
            ArrayHistory<LatencyStatPoint> history = latencyStatPointHistoryMap.get(intPGID);
            if (history == null) {
                history = new ArrayHistory<>(HISTORY_SIZE);
                latencyStatPointHistoryMap.put(intPGID, history);
            }
            history.add(statsFlowHistoryPoint);
            histogramKeysSet.addAll(latencyStat.getLat().getHistogram().keySet());
            latencyStatPointShadowMap.putIfAbsent(intPGID, statsFlowHistoryPoint);
        });
        histogramKeys = new String[histogramKeysSet.size()];
        histogramKeysSet.toArray(histogramKeys);
        Arrays.sort(histogramKeys, PGIDStatsStorage::compareHistogramKeys);
        unvisitedStreams.forEach((final Integer pgID) -> {
            latencyStatPointHistoryMap.remove(pgID);
            latencyStatPointShadowMap.remove(pgID);
        });
    }
}
Also used : LatencyStat(com.cisco.trex.stateless.model.stats.LatencyStat) FlowStatPoint(com.exalttech.trex.ui.models.stats.FlowStatPoint) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint)

Example 3 with LatencyStatPoint

use of com.exalttech.trex.ui.models.stats.LatencyStatPoint 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)

Example 4 with LatencyStatPoint

use of com.exalttech.trex.ui.models.stats.LatencyStatPoint 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++;
            }
        }
    }
}
Also used : ArrayHistory(com.exalttech.trex.util.ArrayHistory) LatencyStatLat(com.cisco.trex.stateless.model.stats.LatencyStatLat) 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) FlowStatPoint(com.exalttech.trex.ui.models.stats.FlowStatPoint) HashMap(java.util.HashMap) Map(java.util.Map) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint)

Example 5 with LatencyStatPoint

use of com.exalttech.trex.ui.models.stats.LatencyStatPoint in project trex-stateless-gui by cisco-system-traffic-generator.

the class LatencyHistogram method render.

public void render() {
    histogram.getData().clear();
    xAxis.setAutoRanging(true);
    final StatsStorage statsStorage = StatsStorage.getInstance();
    final Map<Integer, String> selectedPGIDs = statsStorage.getPGIDsStorage().getSelectedPGIds();
    final PGIDStatsStorage pgIDStatsStorage = statsStorage.getPGIDStatsStorage();
    final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap = pgIDStatsStorage.getLatencyStatPointHistoryMap();
    final Map<Integer, LatencyStatPoint> latencyStatPointShadowMap = pgIDStatsStorage.getLatencyStatPointShadowMap();
    final String[] histogramKeys = pgIDStatsStorage.getHistogramKeys(HISTOGRAM_SIZE);
    final List<XYChart.Series<String, Long>> seriesList = new LinkedList<>();
    synchronized (pgIDStatsStorage.getLatencyLock()) {
        latencyStatPointHistoryMap.forEach((final Integer pgID, final ArrayHistory<LatencyStatPoint> history) -> {
            if (history == null || history.isEmpty()) {
                return;
            }
            final String color = selectedPGIDs.get(pgID);
            if (color == null) {
                return;
            }
            final LatencyStatPoint latencyShadow = latencyStatPointShadowMap.get(pgID);
            final Map<String, Long> shadowHistogram = latencyShadow != null ? latencyShadow.getLatencyStat().getLat().getHistogram() : new HashMap<>();
            final Map<String, Long> histogram = history.last().getLatencyStat().getLat().getHistogram();
            final XYChart.Series<String, Long> series = new XYChart.Series<>();
            series.setName(String.valueOf(pgID));
            for (final String key : histogramKeys) {
                final long value = histogram.getOrDefault(key, 0L);
                final long shadowValue = shadowHistogram.getOrDefault(key, 0L);
                series.getData().add(new XYChart.Data<>(key, value - shadowValue));
            }
            setSeriesColor(series, color);
            seriesList.add(series);
        });
    }
    if (seriesList.isEmpty()) {
        return;
    }
    histogram.getData().addAll(seriesList);
    xAxis.setAutoRanging(true);
}
Also used : ArrayHistory(com.exalttech.trex.util.ArrayHistory) PGIDStatsStorage(com.exalttech.trex.ui.views.storages.PGIDStatsStorage) StatsStorage(com.exalttech.trex.ui.views.storages.StatsStorage) LinkedList(java.util.LinkedList) PGIDStatsStorage(com.exalttech.trex.ui.views.storages.PGIDStatsStorage) XYChart(javafx.scene.chart.XYChart) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint)

Aggregations

LatencyStatPoint (com.exalttech.trex.ui.models.stats.LatencyStatPoint)6 ArrayHistory (com.exalttech.trex.util.ArrayHistory)5 PGIDStatsStorage (com.exalttech.trex.ui.views.storages.PGIDStatsStorage)4 LatencyStat (com.cisco.trex.stateless.model.stats.LatencyStat)3 FlowStatPoint (com.exalttech.trex.ui.models.stats.FlowStatPoint)3 HeaderCell (com.exalttech.trex.ui.views.statistics.cells.HeaderCell)2 StatisticLabelCell (com.exalttech.trex.ui.views.statistics.cells.StatisticLabelCell)2 StatsStorage (com.exalttech.trex.ui.views.storages.StatsStorage)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 XYChart (javafx.scene.chart.XYChart)2 LatencyStatErr (com.cisco.trex.stateless.model.stats.LatencyStatErr)1 LatencyStatLat (com.cisco.trex.stateless.model.stats.LatencyStatLat)1