Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Captain.B 2020-04-13 19:04:45 +08:00
commit eead5f2e3f
1 changed files with 21 additions and 7 deletions

View File

@ -104,7 +104,7 @@ public class JtlResolver {
String average = decimalFormat.format((float) oneLineElapsedTime / jtlSamplesSize);
requestStatistics.setAverage(average);
/**
/*
* TP90的计算
* 1把一段时间内全部的请求的响应时间从小到大排序获得序列A
* 2总的请求数量乘以90%获得90%对应的请求个数C
@ -123,7 +123,7 @@ public class JtlResolver {
requestStatistics.setMax(elapsedList.get(jtlSamplesSize - 1) + "");
requestStatistics.setErrors(decimalFormat.format(failSize * 100.0 / jtlSamplesSize) + "%");
requestStatistics.setKo(failSize);
/**
/*
* 所有的相同请求的bytes总和 / 1024 / 请求持续运行的时间=sum(bytes)/1024/total time
* total time = 最大时间戳 - 最小时间戳 + 最后请求的响应时间
*/
@ -268,20 +268,34 @@ public class JtlResolver {
DecimalFormat decimalFormat = new DecimalFormat("0.00");
List<Metric> totalLineList = JtlResolver.resolver(jtlString);
// todo
List<Metric> totalLineList2 = JtlResolver.resolver(jtlString);
// 时间戳转时间
for (Metric metric : totalLineList2) {
metric.setTimestamp(stampToDate(DATE_TIME_PATTERN, metric.getTimestamp()));
}
Map<String, List<Metric>> collect2 = Objects.requireNonNull(totalLineList2).stream().collect(Collectors.groupingBy(Metric::getTimestamp));
List<Map.Entry<String, List<Metric>>> entries = new ArrayList<>(collect2.entrySet());
int maxUsers = 0;
for (Map.Entry<String, List<Metric>> entry : entries) {
List<Metric> metrics = entry.getValue();
Map<String, List<Metric>> metricsMap = metrics.stream().collect(Collectors.groupingBy(Metric::getThreadName));
if (metricsMap.size() > maxUsers) {
maxUsers = metricsMap.size();
}
}
Map<String, List<Metric>> collect = totalLineList.stream().collect(Collectors.groupingBy(Metric::getTimestamp));
Iterator<Map.Entry<String, List<Metric>>> iterator = collect.entrySet().iterator();
int maxUsers = 0, totalElapsed = 0;
int totalElapsed = 0;
float totalBytes = 0f;
while (iterator.hasNext()) {
Map.Entry<String, List<Metric>> entry = iterator.next();
List<Metric> metricList = entry.getValue();
if (metricList.size() > maxUsers) {
maxUsers = metricList.size();
}
for (Metric metric : metricList) {
String elapsed = metric.getElapsed();
totalElapsed += Integer.parseInt(elapsed);