diff --git a/test-common/src/main/java/com/test/common/utils/HttpSampleAnalyzer.java b/test-common/src/main/java/com/test/common/utils/HttpSampleAnalyzer.java index e430d88..e913bc6 100644 --- a/test-common/src/main/java/com/test/common/utils/HttpSampleAnalyzer.java +++ b/test-common/src/main/java/com/test/common/utils/HttpSampleAnalyzer.java @@ -87,7 +87,7 @@ public class HttpSampleAnalyzer { samplesByInterface.forEach((interfaceName, interfaceSamples) -> { // 过滤出该接口的错误请求 List errorSamples = interfaceSamples.stream() - .filter(s -> !"true".equals(s.getS())) + .filter(s -> !s.getS()) .collect(Collectors.toList()); // 按错误码统计 @@ -116,7 +116,7 @@ public class HttpSampleAnalyzer { samplesByInterface.forEach((interfaceName, interfaceSamples) -> { long total = interfaceSamples.size(); long errors = interfaceSamples.stream() - .filter(s -> !"true".equals(s.getS())) + .filter(s -> !s.getS()) .count(); result.put(interfaceName, new InterfaceErrorStat(interfaceName, total, errors)); diff --git a/test-common/src/main/java/com/test/common/utils/JMeterGroupUtil.java b/test-common/src/main/java/com/test/common/utils/JMeterGroupUtil.java index d1f69d0..5e46c9f 100644 --- a/test-common/src/main/java/com/test/common/utils/JMeterGroupUtil.java +++ b/test-common/src/main/java/com/test/common/utils/JMeterGroupUtil.java @@ -490,7 +490,7 @@ public class JMeterGroupUtil { sampleSaveConfiguration.setSamplerData(true); sampleSaveConfiguration.setAsXml(true); sampleSaveConfiguration.setFieldNames(true); - sampleSaveConfiguration.setResponseHeaders(true); + sampleSaveConfiguration.setResponseHeaders(false); sampleSaveConfiguration.setRequestHeaders(false); sampleSaveConfiguration.setAssertionResultsFailureMessage(true); //sampleSaveConfiguration.setsserAtionsResultsToSave(0); assertionsResultsToSave @@ -549,23 +549,26 @@ public class JMeterGroupUtil { // 初始化统计变量 Map labelStatsMap = new LinkedHashMap<>(); List samples = new ArrayList<>(); - long startTime = Long.MAX_VALUE; - long endTime = Long.MIN_VALUE; +// long startTime = Long.MAX_VALUE; +// long endTime = Long.MIN_VALUE; long totalRequests = 0; long failedRequests = 0; long totalResponseTime = 0; long totalMinResponseTime = Long.MAX_VALUE; long totalMaxResponseTime = Long.MIN_VALUE; + long totalTimeMillis = 0; for (int i = 0; i < httpSampleList.getLength(); i++) { Node httpSampleNode = httpSampleList.item(i); if (httpSampleNode.getNodeType() == Node.ELEMENT_NODE) { - Map resultMap = new HashMap<>(); Element httpSampleElement = (Element) httpSampleNode; // 提取字段 String label = httpSampleElement.getAttribute("lb"); boolean success = Boolean.parseBoolean(httpSampleElement.getAttribute("s")); long responseTime = Long.parseLong(httpSampleElement.getAttribute("t")); - long timestamp = Long.parseLong(httpSampleElement.getAttribute("ts")); + long lt = Long.parseLong(httpSampleElement.getAttribute("lt")); + long ct = Long.parseLong(httpSampleElement.getAttribute("ct")); + totalTimeMillis += responseTime + lt + ct; +// long timestamp = Long.parseLong(httpSampleElement.getAttribute("ts")); long receivedBytes = Long.parseLong(httpSampleElement.getAttribute("by")); long sentBytes = Long.parseLong(httpSampleElement.getAttribute("sby")); String responseCode = httpSampleElement.getAttribute("rc"); @@ -579,8 +582,8 @@ public class JMeterGroupUtil { if (!success) { failedRequests++; } - startTime = Math.min(startTime, timestamp); - endTime = Math.max(endTime, timestamp); +// startTime = Math.min(startTime, timestamp); +// endTime = Math.max(endTime, timestamp); // 更新按标签的统计 LabelStats stats = labelStatsMap.getOrDefault(label, new LabelStats()); stats.totalRequests++; @@ -596,7 +599,8 @@ public class JMeterGroupUtil { } } // 计算总时长(秒) - double totalTimeInSeconds = (endTime - startTime) / 1000.0; + double totalTimeInSeconds = totalTimeMillis / 1000.0; +// double totalTimeInSeconds2 = (endTime - startTime) / 1000.0; // 输出汇总报告 for (Map.Entry entry : labelStatsMap.entrySet()) {