diff --git a/backend/src/main/java/io/metersphere/report/JtlResolver.java b/backend/src/main/java/io/metersphere/report/JtlResolver.java index 3f2490d9e0..ba423a1ac8 100644 --- a/backend/src/main/java/io/metersphere/report/JtlResolver.java +++ b/backend/src/main/java/io/metersphere/report/JtlResolver.java @@ -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 totalLineList = JtlResolver.resolver(jtlString); + // todo + List totalLineList2 = JtlResolver.resolver(jtlString); + // 时间戳转时间 + for (Metric metric : totalLineList2) { + metric.setTimestamp(stampToDate(DATE_TIME_PATTERN, metric.getTimestamp())); + } + + Map> collect2 = Objects.requireNonNull(totalLineList2).stream().collect(Collectors.groupingBy(Metric::getTimestamp)); + List>> entries = new ArrayList<>(collect2.entrySet()); + int maxUsers = 0; + for (Map.Entry> entry : entries) { + List metrics = entry.getValue(); + Map> metricsMap = metrics.stream().collect(Collectors.groupingBy(Metric::getThreadName)); + if (metricsMap.size() > maxUsers) { + maxUsers = metricsMap.size(); + } + } + Map> collect = totalLineList.stream().collect(Collectors.groupingBy(Metric::getTimestamp)); Iterator>> iterator = collect.entrySet().iterator(); - int maxUsers = 0, totalElapsed = 0; + int totalElapsed = 0; float totalBytes = 0f; while (iterator.hasNext()) { Map.Entry> entry = iterator.next(); List metricList = entry.getValue(); - if (metricList.size() > maxUsers) { - maxUsers = metricList.size(); - } - for (Metric metric : metricList) { String elapsed = metric.getElapsed(); totalElapsed += Integer.parseInt(elapsed);