Upgrade to Spring Boot 3.3
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data.benchmark</groupId>
|
||||
<artifactId>spring-data-benchmark-parent</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-data-benchmark-support</artifactId>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<RunResult> 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<RunResult> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<RunResult> 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;
|
||||
|
||||
Reference in New Issue
Block a user