You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by kb...@apache.org on 2023/11/13 08:32:53 UTC
(incubator-kie-kogito-benchmarks) 26/38: BAQE-2006 - Include loadTest metrics in the CSV report
This is an automated email from the ASF dual-hosted git repository.
kbowers pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-kogito-benchmarks.git
commit c72634ebc991accb9f3ee3fb39a5f61bcb57c5bf
Author: Marián Macik <mm...@redhat.com>
AuthorDate: Thu Aug 5 20:53:22 2021 +0200
BAQE-2006 - Include loadTest metrics in the CSV report
---
.../kogito/benchmarks/framework/LogBuilder.java | 51 ++++++++++++++++++++++
.../kogito/benchmarks/AbstractTemplateTest.java | 20 ++++++---
2 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/kogito-benchmarks-framework/src/main/java/org/kie/kogito/benchmarks/framework/LogBuilder.java b/kogito-benchmarks-framework/src/main/java/org/kie/kogito/benchmarks/framework/LogBuilder.java
index 90ddfd7..da2888c 100644
--- a/kogito-benchmarks-framework/src/main/java/org/kie/kogito/benchmarks/framework/LogBuilder.java
+++ b/kogito-benchmarks-framework/src/main/java/org/kie/kogito/benchmarks/framework/LogBuilder.java
@@ -46,7 +46,13 @@ public class LogBuilder {
private static final String rssKbHeader = "RSSKb";
private long rssKb = -1L;
private static final String rssKbFinalHeader = "RSSKbFinal";
+ private static final String avgResponseTimeHeader = "avgResponseTimeMs";
+ private static final String firstResponseTimeHeader = "firstResponseTimeMs";
+ private static final String totalDurationHeader = "totalDurationS";
private long rssKbFinal = -1L;
+ private double avgResponseTime = -1.0;
+ private double firstResponseTime = -1.0;
+ private double totalDuration = -1.0;
private static final String openedFilesHeader = "FDs";
private long openedFiles = -1L;
private static final String appHeader = "App";
@@ -110,6 +116,30 @@ public class LogBuilder {
return this;
}
+ public LogBuilder avgResponseTime(double avgResponseTime) {
+ if (avgResponseTime <= 0) {
+ throw new IllegalArgumentException("avgResponseTime must be a positive double, was: " + rssKb);
+ }
+ this.avgResponseTime = avgResponseTime;
+ return this;
+ }
+
+ public LogBuilder firstResponseTime(double firstResponseTime) {
+ if (firstResponseTime <= 0) {
+ throw new IllegalArgumentException("firstResponseTime must be a positive double, was: " + rssKb);
+ }
+ this.firstResponseTime = firstResponseTime;
+ return this;
+ }
+
+ public LogBuilder totalDuration(double totalDuration) {
+ if (totalDuration <= 0) {
+ throw new IllegalArgumentException("totalDuration must be a positive double, was: " + rssKb);
+ }
+ this.totalDuration = totalDuration;
+ return this;
+ }
+
public LogBuilder openedFiles(long openedFiles) {
if (openedFiles <= 0) {
throw new IllegalArgumentException("openedFiles must be a positive long, was: " + openedFiles);
@@ -197,6 +227,27 @@ public class LogBuilder {
l.append(',');
sections++;
}
+ if (avgResponseTime != -1L) {
+ h.append(avgResponseTimeHeader);
+ h.append(',');
+ l.append(avgResponseTime);
+ l.append(',');
+ sections++;
+ }
+ if (firstResponseTime != -1L) {
+ h.append(firstResponseTimeHeader);
+ h.append(',');
+ l.append(firstResponseTime);
+ l.append(',');
+ sections++;
+ }
+ if (totalDuration != -1L) {
+ h.append(totalDurationHeader);
+ h.append(',');
+ l.append(totalDuration);
+ l.append(',');
+ sections++;
+ }
if (openedFiles != -1L) {
h.append(openedFilesHeader);
h.append(',');
diff --git a/kogito-benchmarks-tests/src/test/java/org/kie/kogito/benchmarks/AbstractTemplateTest.java b/kogito-benchmarks-tests/src/test/java/org/kie/kogito/benchmarks/AbstractTemplateTest.java
index 0f99132..d1ecaf7 100644
--- a/kogito-benchmarks-tests/src/test/java/org/kie/kogito/benchmarks/AbstractTemplateTest.java
+++ b/kogito-benchmarks-tests/src/test/java/org/kie/kogito/benchmarks/AbstractTemplateTest.java
@@ -22,7 +22,7 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.stream.Collectors;
+import java.util.concurrent.TimeUnit;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
@@ -71,6 +71,9 @@ public abstract class AbstractTemplateTest {
public static final int CPU_AFFINITY = Integer.parseInt(System.getProperty("cpuAffinity"));
public static final String LOCALHOST = "http://localhost:8080";
+ private static final double NANOS_IN_MILLISECOND = TimeUnit.MILLISECONDS.toNanos(1);
+ private static final double MILLIS_IN_SECOND = TimeUnit.SECONDS.toMillis(1);
+
public void startStop(TestInfo testInfo, App app) throws IOException, InterruptedException {
logger.info("Running startStop test. Testing app: " + app.toString() + ", mode: " + app.mavenCommands.toString());
@@ -312,12 +315,9 @@ public abstract class AbstractTemplateTest {
totalDuration = endTime - startTime;
}
- // Intentionally left here until a proper reporting to a file is present
- System.out.println("First response time: " + firstResponseTime);
- System.out.println("First response times: " + values.stream().limit(100).collect(Collectors.toList()));
- System.out.println("Last response times: " + values.stream().skip(values.size() - 100).collect(Collectors.toList()));
- System.out.println("Average response time: " + values.stream().mapToLong(Long::longValue).average());
- System.out.println("Total duration: " + totalDuration);
+ double avgResponseTimeMs = values.stream().mapToLong(Long::longValue).average().orElse(-1) / NANOS_IN_MILLISECOND;
+ double firstResponseTimeMs = firstResponseTime / NANOS_IN_MILLISECOND;
+ double totalDurationS = totalDuration / MILLIS_IN_SECOND;
long rssKbFinal = getRSSkB(pA.pid());
long openedFiles = getOpenedFDs(pA.pid()); // TODO also do before the "test" itself? Maybe not needed as before is covered in a startStop test
@@ -347,6 +347,9 @@ public abstract class AbstractTemplateTest {
.stoppedInMs(stoppedInMs)
.rssKb(rssKb)
.rssKbFinal(rssKbFinal)
+ .avgResponseTime(avgResponseTimeMs)
+ .firstResponseTime(firstResponseTimeMs)
+ .totalDuration(totalDurationS)
.openedFiles(openedFiles)
.build();
@@ -356,6 +359,9 @@ public abstract class AbstractTemplateTest {
.app(app)
.mode(mvnCmds)
.rssKbFinal(rssKbFinal)
+ .avgResponseTime(avgResponseTimeMs)
+ .firstResponseTime(firstResponseTimeMs)
+ .totalDuration(totalDurationS)
.build();
Logs.logMeasurementsSummary(summaryLog, measurementsSummaryLog);
appendln(whatIDidReport, "Measurements:");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org