From 4e011d2d07715ccd9b9c0a64911e4b37cca48dd0 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 14 Jul 2023 18:00:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=89=A7=E8=A1=8C=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E8=BD=AC=E5=8C=96=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1027856 --user=刘瑞斌 【性能测试】自定义节点-一直starting https://www.tapd.cn/55049933/s/1393790 --- .../java/io/metersphere/engine/EngineFactory.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/performance-test/backend/src/main/java/io/metersphere/engine/EngineFactory.java b/performance-test/backend/src/main/java/io/metersphere/engine/EngineFactory.java index 78bf0ad26b..8cba204492 100644 --- a/performance-test/backend/src/main/java/io/metersphere/engine/EngineFactory.java +++ b/performance-test/backend/src/main/java/io/metersphere/engine/EngineFactory.java @@ -15,6 +15,7 @@ import io.metersphere.parse.EngineSourceParser; import io.metersphere.parse.EngineSourceParserFactory; import io.metersphere.service.BaseTestResourcePoolService; import io.metersphere.service.PerformanceReportService; +import jakarta.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; @@ -23,9 +24,9 @@ import org.dom4j.Element; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; @@ -149,11 +150,19 @@ public class EngineFactory { if (resourceIndex + 1 == tgRatios.size()) { double beforeLast = 0; // 前几个线程数 for (int k = 0; k < tgRatios.size() - 1; k++) { - beforeLast += Math.round(threadNum2 * (double) tgRatios.get(k)); + if (tgRatios.get(k) instanceof BigDecimal) { + beforeLast += Math.round(threadNum2 * ((BigDecimal) tgRatios.get(k)).floatValue()); + } else { + beforeLast += Math.round(threadNum2 * (double) tgRatios.get(k)); + } } value = Math.round(threadNum2 - beforeLast); } else { - value = Math.round(threadNum2 * (double) tgRatios.get(resourceIndex)); + if (tgRatios.get(resourceIndex) instanceof BigDecimal) { + value = Math.round(threadNum2 * ((BigDecimal) tgRatios.get(resourceIndex)).floatValue()); + } else { + value = Math.round(threadNum2 * (double) tgRatios.get(resourceIndex)); + } } } break;