Some examples for spotting potential performance regressions using JfrUnit.
This project requires OpenJDK 17 and Apache Maven for its build.
Run the following to build the project:
cd user-service
mvn clean verify
java -Dquarkus.http.port=8082 -jar target/jfrunit-demo-user-1.0.0-SNAPSHOT-runner.jar
This starts the "user" service, which is accessed by the example service within one of the regression scenarios. Then build the example service itself:
cd example-service
mvn clean verify
In each test class, there's a method ...Regression()
which is commented out.
When commenting it in, this test should fail due to a performance "regresssion",
e.g. due to higher memory allocation than expected, more IO, or more SQL statements.
JMC Agent is used in the TodoResourceSqlStatementsTest
for emitting JFR events from Hibernate / its connection pool.
As JMC Agent isn't available as a Maven dependency on Maven Central,
it is retrieved using the download-maven-plugin
from the https://github.com/adoptium/jmc-overrides/releases[Adoptium JMC Overrides project].
When running the TodoResourceSqlStatementsTest
in your IDE, make sure to specify the correct JMC Agent configuration,
as seen in the example-service/pom.xml file.
For manual testing, build the application, start a separate Postgres instance via Docker Compose and launch the app like so:
docker-compose up
cd example-service
clean verify -DskipTests=true
java -jar ./example-service/target/quarkus-app/quarkus-run.jar
# Testing, e.g. via httpie
http POST localhost:8080/todo title=Test priority=2 completed=true
This code base is available under the Apache License, version 2.