use of org.apache.jmeter.report.processor.MapResultData 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);
}
}
}
use of org.apache.jmeter.report.processor.MapResultData 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;
}
use of org.apache.jmeter.report.processor.MapResultData in project jmeter by apache.
the class AbstractDataExporter method findData.
/**
* Finds a inner ResultData matching the specified data name in a ResultData
* tree. Supports only MapResultData walking.
*
* @param data
* the name of the data containing the value
* @param root
* the root of the tree
* @return the ResultData matching the data name
*/
protected static ResultData findData(String data, ResultData root) {
String[] pathItems = StringUtils.split(data, '.');
if (pathItems == null || !(root instanceof MapResultData)) {
return null;
}
ResultData result = null;
int count = pathItems.length;
int index = 0;
MapResultData map = (MapResultData) root;
while (index < count && result == null) {
ResultData current = map.getResult(pathItems[index]);
if (index == count - 1) {
result = current;
} else {
if (current instanceof MapResultData) {
map = (MapResultData) current;
index++;
}
}
}
return result;
}
use of org.apache.jmeter.report.processor.MapResultData in project jmeter by apache.
the class CustomGraphConsumerTest method init.
@BeforeEach
public void init() {
customGraphConsumer = new CustomGraphConsumer();
customGraphConsumer.setGranularity(60000);
customGraphConsumer.setTitle("graph title");
customGraphConsumer.setXAxis("X axis name");
customGraphConsumer.setYAxis("Y axis name");
customGraphConsumer.setContentMessage("content message");
customGraphConsumer.setSampleVariableName("ulp_lag_ratio");
map = customGraphConsumer.createGroupInfos();
resultData = new MapResultData();
}
use of org.apache.jmeter.report.processor.MapResultData in project jmeter by apache.
the class SyntheticResponseTimeDistributionGraphConsumer method create.
private MapResultData create(String serie, String color) {
GroupInfo groupInfo = getGroupInfos().get(AbstractGraphConsumer.DEFAULT_GROUP);
SeriesData seriesData = new SeriesData(groupInfo.getAggregatorFactory(), groupInfo.enablesAggregatedKeysSeries(), false, groupInfo.enablesOverallSeries());
MapResultData seriesResult = createSerieResult(serie, seriesData);
seriesResult.setResult(SERIE_COLOR_PROPERTY, new ValueResultData(color));
return seriesResult;
}
Aggregations