diff --git a/benchmark/commons/pom.xml b/benchmark/commons/pom.xml
index 55f4fd6..f43fc18 100644
--- a/benchmark/commons/pom.xml
+++ b/benchmark/commons/pom.xml
@@ -7,7 +7,7 @@
org.springframework.data.benchmark
spring-data-benchmark-parent
- 2.5.0-SNAPSHOT
+ 3.3.0-SNAPSHOT
spring-data-benchmark-commons
diff --git a/benchmark/mongodb/pom.xml b/benchmark/mongodb/pom.xml
index bca9491..242dc46 100644
--- a/benchmark/mongodb/pom.xml
+++ b/benchmark/mongodb/pom.xml
@@ -7,7 +7,7 @@
org.springframework.data.benchmark
spring-data-benchmark-parent
- 2.5.0-SNAPSHOT
+ 3.3.0-SNAPSHOT
spring-data-benchmark-mongodb
@@ -34,6 +34,7 @@
de.flapdoodle.embed
de.flapdoodle.embed.mongo
+ 4.12.2
runtime
diff --git a/benchmark/pom.xml b/benchmark/pom.xml
index b5b479f..16bb5ac 100644
--- a/benchmark/pom.xml
+++ b/benchmark/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
@@ -15,7 +15,8 @@
org.springframework.data.build
spring-data-parent
- 2.5.0-SNAPSHOT
+ 3.3.0-SNAPSHOT
+
@@ -27,7 +28,7 @@
- 1.19
+ 1.37
@@ -36,7 +37,15 @@
org.springframework.boot
spring-boot-dependencies
- 2.5.0-SNAPSHOT
+ 3.3.0-SNAPSHOT
+ pom
+ import
+
+
+
+ org.springframework.data
+ spring-data-bom
+ 2024.0.0-SNAPSHOT
pom
import
@@ -50,19 +59,19 @@
com.github.mp911de.microbenchmark-runner
microbenchmark-runner-junit4
- 0.2.0.RELEASE
+ 0.4.0.RELEASE
com.github.mp911de.microbenchmark-runner
microbenchmark-runner-extras
- 0.2.0.RELEASE
+ 0.4.0.RELEASE
net.minidev
json-smart
- 2.4.4
+ 2.5.0
@@ -107,10 +116,10 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.8.1
+ 3.10.1
- 1.8
- 1.8
+ 17
+ 17
true
@@ -129,8 +138,10 @@
maven-surefire-plugin
- ${project.build.sourceDirectory}
- ${project.build.outputDirectory}
+ ${project.build.sourceDirectory}
+
+ ${project.build.outputDirectory}
+
**/AbstractMicrobenchmark.java
**/*$*.class
@@ -140,7 +151,9 @@
**/*Benchmark*
- ${project.build.directory}/reports/performance
+
+ ${project.build.directory}/reports/performance
+
${project.version}
${git.dirty}
${git.commit.id}
@@ -153,9 +166,15 @@
- spring-libs-snapshot
- https://repo.spring.io/libs-snapshot
+ spring-snapshot
+ https://repo.spring.io/snapshot
+
+
+ spring-milestone
+ https://repo.spring.io/milestone
+
+
jitpack.io
https://jitpack.io
diff --git a/benchmark/redis/pom.xml b/benchmark/redis/pom.xml
index 6e9016a..dc581b3 100644
--- a/benchmark/redis/pom.xml
+++ b/benchmark/redis/pom.xml
@@ -8,7 +8,7 @@
org.springframework.data.benchmark
spring-data-benchmark-parent
- 2.5.0-SNAPSHOT
+ 3.3.0-SNAPSHOT
spring-data-benchmark-redis
diff --git a/benchmark/relational/pom.xml b/benchmark/relational/pom.xml
index 9a22950..2760b1d 100644
--- a/benchmark/relational/pom.xml
+++ b/benchmark/relational/pom.xml
@@ -7,7 +7,7 @@
org.springframework.data.benchmark
spring-data-benchmark-parent
- 2.5.0-SNAPSHOT
+ 3.3.0-SNAPSHOT
spring-data-benchmark-relational
@@ -54,7 +54,7 @@
- io.r2dbc
+ org.postgresql
r2dbc-postgresql
diff --git a/benchmark/relational/src/main/java/org/springframework/data/microbenchmark/r2dbc/R2dbcBenchmark.java b/benchmark/relational/src/main/java/org/springframework/data/microbenchmark/r2dbc/R2dbcBenchmark.java
index e4eb785..79e7cf6 100644
--- a/benchmark/relational/src/main/java/org/springframework/data/microbenchmark/r2dbc/R2dbcBenchmark.java
+++ b/benchmark/relational/src/main/java/org/springframework/data/microbenchmark/r2dbc/R2dbcBenchmark.java
@@ -15,6 +15,7 @@
*/
package org.springframework.data.microbenchmark.r2dbc;
+import io.r2dbc.spi.Readable;
import io.r2dbc.spi.Row;
import java.util.function.Function;
@@ -26,7 +27,7 @@ import org.openjdk.jmh.infra.Blackhole;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.microbenchmark.common.AbstractMicrobenchmark;
-import org.springframework.data.r2dbc.core.DatabaseClient;
+import org.springframework.r2dbc.core.DatabaseClient;
/**
* Benchmark for R2DBC and Spring Data R2DBC
@@ -41,7 +42,7 @@ public class R2dbcBenchmark extends AbstractMicrobenchmark {
@Param({ /* "postgres", */ "h2-in-memory" /*, "h2" */ }) String profile;
private DatabaseClient operations;
- private Function mapper;
+ private Function mapper;
private R2dbcBookRepository repository;
@@ -62,7 +63,7 @@ public class R2dbcBenchmark extends AbstractMicrobenchmark {
@Benchmark
public void findByTitle(Blackhole sink) {
- sink.consume(operations.execute(BY_TITLE_SQL) //
+ sink.consume(operations.sql(BY_TITLE_SQL) //
.bind("title", "title0") //
.map(mapper).one() //
.block());
@@ -71,7 +72,7 @@ public class R2dbcBenchmark extends AbstractMicrobenchmark {
@Benchmark
public void findAll(Blackhole sink) {
- sink.consume(operations.execute(FIND_ALL_SQL) //
+ sink.consume(operations.sql(FIND_ALL_SQL) //
.map(mapper) //
.all() //
.collectList() //
diff --git a/benchmark/support/pom.xml b/benchmark/support/pom.xml
index c6bfaf5..4ade98d 100644
--- a/benchmark/support/pom.xml
+++ b/benchmark/support/pom.xml
@@ -7,7 +7,7 @@
org.springframework.data.benchmark
spring-data-benchmark-parent
- 2.5.0-SNAPSHOT
+ 3.3.0-SNAPSHOT
spring-data-benchmark-support
diff --git a/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/AbstractMicrobenchmark.java b/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/AbstractMicrobenchmark.java
index c39b2b4..16dc075 100644
--- a/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/AbstractMicrobenchmark.java
+++ b/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/AbstractMicrobenchmark.java
@@ -31,8 +31,8 @@ import org.openjdk.jmh.annotations.Warmup;
* @author Mark Paluch
* @see Microbenchmark
*/
-@Warmup(iterations = 10)
-@Measurement(iterations = 10)
+@Warmup(iterations = 10, time = 2)
+@Measurement(iterations = 10, time = 2)
@Fork(value = 1, jvmArgs = { "-server", "-XX:+HeapDumpOnOutOfMemoryError", "-Xms1024m", "-Xmx1024m",
"-XX:MaxDirectMemorySize=1024m", "-noverify" })
@State(Scope.Thread)
diff --git a/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/HttpResultsWriter.java b/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/HttpResultsWriter.java
index df5d109..c089a1d 100644
--- a/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/HttpResultsWriter.java
+++ b/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/HttpResultsWriter.java
@@ -16,10 +16,13 @@
package org.springframework.data.microbenchmark.common;
import jmh.mbr.core.ResultsWriter;
+import jmh.mbr.core.model.BenchmarkResults;
import lombok.RequiredArgsConstructor;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
@@ -27,14 +30,17 @@ import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Collection;
+import lombok.SneakyThrows;
import org.openjdk.jmh.results.RunResult;
+import org.openjdk.jmh.results.format.ResultFormatFactory;
+import org.openjdk.jmh.results.format.ResultFormatType;
import org.openjdk.jmh.runner.format.OutputFormat;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.util.CollectionUtils;
/**
* {@link ResultsWriterOld} implementation of {@link URLConnection}.
- *
+ *
* @author Christoph Strobl
* @author Mark Paluch
*/
@@ -43,17 +49,18 @@ class HttpResultsWriter implements ResultsWriter {
private final String url;
- @Override
- public void write(OutputFormat output, Collection results) {
- if (CollectionUtils.isEmpty(results)) {
+ @Override
+ public void write(OutputFormat output, BenchmarkResults benchmarkResults) {
+
+ if (CollectionUtils.isEmpty(benchmarkResults.getRawResults())) {
return;
}
try {
- doWrite(results);
+ doWrite(benchmarkResults.getRawResults());
} catch (IOException e) {
- output.println("Failed to write results: " + e.toString());
+ output.println("Failed to write results: " + e);
}
}
@@ -79,7 +86,7 @@ class HttpResultsWriter implements ResultsWriter {
connection.addRequestProperty("X-Git-Commit-Id", gitCommitId);
try (OutputStream output = connection.getOutputStream()) {
- output.write(ResultsWriter.jsonifyResults(results).getBytes(StandardCharsets.UTF_8));
+ output.write(jsonifyResults(results).getBytes(StandardCharsets.UTF_8));
}
if (connection.getResponseCode() >= 400) {
@@ -87,4 +94,20 @@ class HttpResultsWriter implements ResultsWriter {
String.format("Status %d %s", connection.getResponseCode(), connection.getResponseMessage()));
}
}
+
+ /**
+ * Convert {@link RunResult}s to JMH Json representation.
+ *
+ * @param results
+ * @return json string representation of results.
+ * @see org.openjdk.jmh.results.format.JSONResultFormat
+ */
+ @SneakyThrows
+ static String jsonifyResults(Collection results) {
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ResultFormatFactory.getInstance(ResultFormatType.JSON, new PrintStream(baos, true, "UTF-8")).writeOut(results);
+
+ return new String(baos.toByteArray(), StandardCharsets.UTF_8);
+ }
}
diff --git a/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/MongoResultsWriter.java b/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/MongoResultsWriter.java
index d13ad0f..cd519cc 100644
--- a/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/MongoResultsWriter.java
+++ b/benchmark/support/src/main/java/org/springframework/data/microbenchmark/common/MongoResultsWriter.java
@@ -16,6 +16,7 @@
package org.springframework.data.microbenchmark.common;
import jmh.mbr.core.ResultsWriter;
+import jmh.mbr.core.model.BenchmarkResults;
import lombok.RequiredArgsConstructor;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
@@ -52,14 +53,14 @@ class MongoResultsWriter implements ResultsWriter {
private final String uri;
@Override
- public void write(OutputFormat output, Collection results) {
+ public void write(OutputFormat output, BenchmarkResults benchmarkResults) {
- if (CollectionUtils.isEmpty(results)) {
+ if (CollectionUtils.isEmpty(benchmarkResults.getRawResults())) {
return;
}
try {
- doWrite(results);
+ doWrite(benchmarkResults.getRawResults());
} catch (ParseException | RuntimeException e) {
output.println("Failed to write results: " + e.toString());
}
@@ -81,7 +82,7 @@ class MongoResultsWriter implements ResultsWriter {
String dbName = StringUtils.hasText(uri.getDatabase()) ? uri.getDatabase() : "spring-data-mongodb-benchmarks";
MongoDatabase db = client.getDatabase(dbName);
- String resultsJson = ResultsWriter.jsonifyResults(results).trim();
+ String resultsJson = HttpResultsWriter.jsonifyResults(results).trim();
JSONArray array = (JSONArray) new JSONParser(JSONParser.MODE_PERMISSIVE).parse(resultsJson);
for (Object object : array) {
JSONObject dbo = (JSONObject) object;