Search in sources :

Example 1 with ListResultData

use of org.apache.jmeter.report.processor.ListResultData in project jmeter by apache.

the class ResponseTimePerSampleGraphConsumer method initializeExtraResults.

/*
     * (non-Javadoc)
     *
     * @see org.apache.jmeter.report.processor.graph.AbstractGraphConsumer#
     * initializeExtraResults(org.apache.jmeter.report.processor.MapResultData)
     */
@Override
protected void initializeExtraResults(MapResultData parentResult) {
    ListResultData samples = new ListResultData();
    IndexedNameSelector indexedNameSelector = (IndexedNameSelector) getKeysSelector();
    int size = indexedNameSelector.getNames().size();
    for (int i = 0; i < size; i++) {
        samples.addResult(new ValueResultData(indexedNameSelector.getNames().get(i)));
    }
    parentResult.setResult("sampleNames", samples);
}
Also used : IndexedNameSelector(org.apache.jmeter.report.processor.graph.IndexedNameSelector) ListResultData(org.apache.jmeter.report.processor.ListResultData) ValueResultData(org.apache.jmeter.report.processor.ValueResultData)

Example 2 with ListResultData

use of org.apache.jmeter.report.processor.ListResultData in project jmeter by apache.

the class SyntheticResponseTimeDistributionGraphConsumer method initializeExtraResults.

@Override
protected void initializeExtraResults(MapResultData parentResult) {
    ListResultData listResultData = new ListResultData();
    String[] seriesLabels = new String[] { SATISFIED_LABEL.format(new Object[] { getSatisfiedThreshold() }), TOLERATED_LABEL.format(new Object[] { getSatisfiedThreshold(), getToleratedThreshold() }), UNTOLERATED_LABEL.format(new Object[] { getToleratedThreshold() }), FAILED_LABEL };
    String[] colors = new String[] { SATISFIED_COLOR, TOLERATED_COLOR, UNTOLERATED_COLOR, FAILED_COLOR };
    for (int i = 0; i < seriesLabels.length; i++) {
        ListResultData array = new ListResultData();
        array.addResult(new ValueResultData(i));
        array.addResult(new ValueResultData(seriesLabels[i]));
        listResultData.addResult(array);
    }
    parentResult.setResult("ticks", listResultData);
    initializeSeries(parentResult, seriesLabels, colors);
}
Also used : ListResultData(org.apache.jmeter.report.processor.ListResultData) ValueResultData(org.apache.jmeter.report.processor.ValueResultData)

Example 3 with ListResultData

use of org.apache.jmeter.report.processor.ListResultData in project jmeter by apache.

the class AbstractGraphConsumer method addKeyData.

/**
 * Adds a value map build from specified parameters to the result map.
 *
 * @param result     {@link MapResultData}
 * @param group
 * @param series
 * @param seriesData
 * @param aggregated
 */
private void addKeyData(MapResultData result, @SuppressWarnings("unused") String group, String series, SeriesData seriesData, boolean aggregated) {
    // Override series name when aggregated
    if (aggregated) {
        series = String.format(aggregatedKeysSeriesFormat, series);
    }
    // Add to the result map
    ListResultData seriesList = (ListResultData) result.getResult(RESULT_SERIES);
    // Looks for series result using its name
    MapResultData seriesResult = null;
    int index = 0;
    int size = seriesList.getSize();
    while (seriesResult == null && index < size) {
        MapResultData currSeries = (MapResultData) seriesList.get(index);
        String name = String.valueOf(((ValueResultData) currSeries.getResult(RESULT_SERIES_NAME)).getValue());
        if (Objects.equals(name, series)) {
            seriesResult = currSeries;
        }
        index++;
    }
    // Create series result if not found
    if (seriesResult == null) {
        seriesResult = createSerieResult(series, seriesData);
        seriesList.addResult(seriesResult);
    }
    ListResultData dataResult = (ListResultData) seriesResult.getResult(RESULT_SERIES_DATA);
    // Populate it with data from groupData
    Map<Double, Aggregator> aggInfo;
    if (aggregated) {
        aggInfo = new HashMap<>();
        aggInfo.put(seriesData.getKeysAggregator().getResult(), seriesData.getValuesAggregator());
    } else {
        aggInfo = seriesData.getAggregatorInfo();
    }
    if (!renderPercentiles) {
        for (Map.Entry<Double, Aggregator> entry : aggInfo.entrySet()) {
            // Init key and value depending on invertKeysAndValues property
            Double key = entry.getKey();
            Double value = entry.getValue().getResult();
            if (invertKeysAndValues) {
                key = entry.getValue().getResult();
                value = entry.getKey();
            }
            // Create result storage for coordinates
            ListResultData coordResult = new ListResultData();
            coordResult.addResult(new ValueResultData(key));
            coordResult.addResult(new ValueResultData(value));
            dataResult.addResult(coordResult);
            setMinResult(result, RESULT_MIN_X, key);
            setMaxResult(result, RESULT_MAX_X, key);
            setMinResult(result, RESULT_MIN_Y, value);
            setMaxResult(result, RESULT_MAX_Y, value);
        }
    } else {
        long count = seriesData.getCount();
        int rank = 0;
        double percent = 0;
        TreeMap<Double, Aggregator> sortedInfo = new TreeMap<>(aggInfo);
        if (!invertKeysAndValues) {
            for (Map.Entry<Double, Aggregator> entry : sortedInfo.entrySet()) {
                Double value = entry.getKey();
                percent += (double) 100 * entry.getValue().getCount() / count;
                double percentile = (double) rank / 10;
                while (percentile < percent) {
                    ListResultData coordResult = new ListResultData();
                    coordResult.addResult(new ValueResultData(percentile));
                    coordResult.addResult(new ValueResultData(value));
                    dataResult.addResult(coordResult);
                    percentile = (double) ++rank / 10;
                }
                setMinResult(result, RESULT_MIN_Y, value);
                setMaxResult(result, RESULT_MAX_Y, value);
            }
            setMinResult(result, RESULT_MIN_X, 0d);
            setMaxResult(result, RESULT_MAX_X, 100d);
        } else {
            for (Map.Entry<Double, Aggregator> entry : sortedInfo.entrySet()) {
                Double value = entry.getKey();
                percent += (double) 100 * entry.getValue().getCount() / count;
                double percentile = (double) rank / 10;
                while (percentile < percent) {
                    ListResultData coordResult = new ListResultData();
                    coordResult.addResult(new ValueResultData(value));
                    coordResult.addResult(new ValueResultData(percentile));
                    dataResult.addResult(coordResult);
                    percentile = (double) ++rank / 10;
                }
                setMinResult(result, RESULT_MIN_X, value);
                setMaxResult(result, RESULT_MAX_X, value);
            }
            setMinResult(result, RESULT_MIN_Y, 0d);
            setMaxResult(result, RESULT_MAX_Y, 100d);
        }
    }
}
Also used : Aggregator(org.apache.jmeter.report.processor.Aggregator) TreeMap(java.util.TreeMap) MapResultData(org.apache.jmeter.report.processor.MapResultData) ListResultData(org.apache.jmeter.report.processor.ListResultData) TreeMap(java.util.TreeMap) Map(java.util.Map) HashMap(java.util.HashMap) ValueResultData(org.apache.jmeter.report.processor.ValueResultData)

Example 4 with ListResultData

use of org.apache.jmeter.report.processor.ListResultData in project jmeter by apache.

the class AbstractGraphConsumer method createResult.

private MapResultData createResult() {
    MapResultData result = new MapResultData();
    result.setResult(RESULT_MIN_X, new ValueResultData(Double.MAX_VALUE));
    result.setResult(RESULT_MAX_X, new ValueResultData(Double.MIN_VALUE));
    result.setResult(RESULT_MIN_Y, new ValueResultData(Double.MAX_VALUE));
    result.setResult(RESULT_MAX_Y, new ValueResultData(Double.MIN_VALUE));
    result.setResult(RESULT_TITLE, new ValueResultData(getTitle()));
    result.setResult(RESULT_SERIES, new ListResultData());
    boolean supportsControllersDiscrimination = groupInfos.values().stream().map(GroupInfo::getSeriesSelector).allMatch(GraphSeriesSelector::allowsControllersDiscrimination);
    result.setResult(RESULT_SUPPORTS_CONTROLLERS_DISCRIMINATION, new ValueResultData(supportsControllersDiscrimination));
    initializeExtraResults(result);
    return result;
}
Also used : MapResultData(org.apache.jmeter.report.processor.MapResultData) ValueResultData(org.apache.jmeter.report.processor.ValueResultData) ListResultData(org.apache.jmeter.report.processor.ListResultData)

Example 5 with ListResultData

use of org.apache.jmeter.report.processor.ListResultData in project jmeter by apache.

the class JsonExporter method createStatistic.

private void createStatistic(Map<String, SamplingStatistic> statistics, MapResultData resultData) {
    LOGGER.debug("Creating statistics for result data:{}", resultData);
    SamplingStatistic statistic = new SamplingStatistic();
    ListResultData listResultData = (ListResultData) resultData.getResult("data");
    statistic.setTransaction((String) ((ValueResultData) listResultData.get(0)).getValue());
    statistic.setSampleCount((Long) ((ValueResultData) listResultData.get(1)).getValue());
    statistic.setErrorCount((Long) ((ValueResultData) listResultData.get(2)).getValue());
    statistic.setErrorPct(((Double) ((ValueResultData) listResultData.get(3)).getValue()).floatValue());
    statistic.setMeanResTime((Double) ((ValueResultData) listResultData.get(4)).getValue());
    statistic.setMinResTime((Long) ((ValueResultData) listResultData.get(5)).getValue());
    statistic.setMaxResTime((Long) ((ValueResultData) listResultData.get(6)).getValue());
    statistic.setMedianResTime((Double) ((ValueResultData) listResultData.get(7)).getValue());
    statistic.setPct1ResTime((Double) ((ValueResultData) listResultData.get(8)).getValue());
    statistic.setPct2ResTime((Double) ((ValueResultData) listResultData.get(9)).getValue());
    statistic.setPct3ResTime((Double) ((ValueResultData) listResultData.get(10)).getValue());
    statistic.setThroughput((Double) ((ValueResultData) listResultData.get(11)).getValue());
    statistic.setReceivedKBytesPerSec((Double) ((ValueResultData) listResultData.get(12)).getValue());
    statistic.setSentKBytesPerSec((Double) ((ValueResultData) listResultData.get(13)).getValue());
    statistics.put(statistic.getTransaction(), statistic);
}
Also used : ListResultData(org.apache.jmeter.report.processor.ListResultData) ValueResultData(org.apache.jmeter.report.processor.ValueResultData)

Aggregations

ListResultData (org.apache.jmeter.report.processor.ListResultData)7 ValueResultData (org.apache.jmeter.report.processor.ValueResultData)6 MapResultData (org.apache.jmeter.report.processor.MapResultData)4 HashMap (java.util.HashMap)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 File (java.io.File)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Aggregator (org.apache.jmeter.report.processor.Aggregator)1 IndexedNameSelector (org.apache.jmeter.report.processor.graph.IndexedNameSelector)1