12 changed files with 23 additions and 209 deletions
@ -1,76 +0,0 @@
@@ -1,76 +0,0 @@
|
||||
# Benchmarks |
||||
|
||||
Benchmarks are based on [JMH](https://openjdk.java.net/projects/code-tools/jmh/). |
||||
|
||||
# Running Benchmarks |
||||
|
||||
Running benchmarks is disabled by default and can be activated via the `benchmarks` profile. |
||||
To run the benchmarks with default settings use. |
||||
|
||||
```bash |
||||
mvn -P benchmarks clean test |
||||
``` |
||||
|
||||
A basic report will be printed to the CLI. |
||||
|
||||
```bash |
||||
# Run complete. Total time: 00:00:15 |
||||
|
||||
Benchmark Mode Cnt Score Error Units |
||||
MappingMongoConverterBenchmark.readObject thrpt 10 1920157,631 ± 64310,809 ops/s |
||||
MappingMongoConverterBenchmark.writeObject thrpt 10 782732,857 ± 53804,130 ops/s |
||||
``` |
||||
|
||||
## Running all Benchmarks of a specific class |
||||
|
||||
To run all Benchmarks of a specific class, just provide its simple class name via the `benchmark` command line argument. |
||||
|
||||
```bash |
||||
mvn -P benchmarks clean test -D benchmark=MappingMongoConverterBenchmark |
||||
``` |
||||
|
||||
## Running a single Benchmark |
||||
|
||||
To run a single Benchmark provide its containing class simple name followed by `#` and the method name via the `benchmark` command line argument. |
||||
|
||||
```bash |
||||
mvn -P benchmarks clean test -D benchmark=MappingMongoConverterBenchmark#readObjectWith2Properties |
||||
``` |
||||
|
||||
# Saving Benchmark Results |
||||
|
||||
A detailed benchmark report is stored in JSON format in the `/target/reports/performance` directory. |
||||
To store the report in a different location use the `benchmarkReportDir` command line argument. |
||||
|
||||
## MongoDB |
||||
|
||||
Results can be directly piped to MongoDB by providing a valid [Connection String](https://docs.mongodb.com/manual/reference/connection-string/) via the `publishTo` command line argument. |
||||
|
||||
```bash |
||||
mvn -P benchmarks clean test -D publishTo=mongodb://127.0.0.1:27017 |
||||
``` |
||||
|
||||
NOTE: If the uri does not explicitly define a database the default `spring-data-mongodb-benchmarks` is used. |
||||
|
||||
## HTTP Endpoint |
||||
|
||||
The benchmark report can also be posted as `application/json` to an HTTP Endpoint by providing a valid URl via the `publishTo` command line argument. |
||||
|
||||
```bash |
||||
mvn -P benchmarks clean test -D publishTo=http://127.0.0.1:8080/capture-benchmarks |
||||
``` |
||||
|
||||
# Customizing Benchmarks |
||||
|
||||
Following options can be set via command line. |
||||
|
||||
Option | Default Value |
||||
--- | --- |
||||
warmupIterations | 10 |
||||
warmupTime | 1 (seconds) |
||||
measurementIterations | 10 |
||||
measurementTime | 1 (seconds) |
||||
forks | 1 |
||||
benchmarkReportDir | /target/reports/performance (always relative to project root dir) |
||||
benchmark | .* (single benchmark via `classname#benchmark`) |
||||
publishTo | \[not set\] (mongodb-uri or http-endpoint) |
||||
@ -1,112 +0,0 @@
@@ -1,112 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd"> |
||||
|
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<parent> |
||||
<groupId>org.springframework.data</groupId> |
||||
<artifactId>spring-data-mongodb-parent</artifactId> |
||||
<version>4.4.0-SNAPSHOT</version> |
||||
<relativePath>../pom.xml</relativePath> |
||||
</parent> |
||||
|
||||
<artifactId>spring-data-mongodb-benchmarks</artifactId> |
||||
<packaging>jar</packaging> |
||||
|
||||
<name>Spring Data MongoDB - Microbenchmarks</name> |
||||
|
||||
<properties> |
||||
<!-- Skip tests by default; run only if -DskipTests=false is specified or benchmarks profile is activated --> |
||||
<skipTests>true</skipTests> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
|
||||
<dependency> |
||||
<groupId>${project.groupId}</groupId> |
||||
<artifactId>spring-data-mongodb</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>junit</groupId> |
||||
<artifactId>junit</artifactId> |
||||
<version>${junit}</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.openjdk.jmh</groupId> |
||||
<artifactId>jmh-core</artifactId> |
||||
<version>${jmh.version}</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.openjdk.jmh</groupId> |
||||
<artifactId>jmh-generator-annprocess</artifactId> |
||||
<version>${jmh.version}</version> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
<profiles> |
||||
|
||||
<profile> |
||||
<id>benchmarks</id> |
||||
<properties> |
||||
<skipTests>false</skipTests> |
||||
</properties> |
||||
</profile> |
||||
</profiles> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>pl.project13.maven</groupId> |
||||
<artifactId>git-commit-id-plugin</artifactId> |
||||
<version>2.2.2</version> |
||||
<executions> |
||||
<execution> |
||||
<goals> |
||||
<goal>revision</goal> |
||||
</goals> |
||||
</execution> |
||||
</executions> |
||||
</plugin> |
||||
<plugin> |
||||
<artifactId>maven-jar-plugin</artifactId> |
||||
<executions> |
||||
<execution> |
||||
<id>default-jar</id> |
||||
<phase>never</phase> |
||||
</execution> |
||||
</executions> |
||||
</plugin> |
||||
<plugin> |
||||
<artifactId>maven-surefire-plugin</artifactId> |
||||
<configuration> |
||||
<useSystemClassLoader>false</useSystemClassLoader> |
||||
<testSourceDirectory>${project.build.sourceDirectory}</testSourceDirectory> |
||||
<testClassesDirectory>${project.build.outputDirectory}</testClassesDirectory> |
||||
<excludes> |
||||
<exclude>**/AbstractMicrobenchmark.java</exclude> |
||||
<exclude>**/*$*.class</exclude> |
||||
<exclude>**/generated/*.class</exclude> |
||||
</excludes> |
||||
<includes> |
||||
<include>**/*Benchmark*</include> |
||||
</includes> |
||||
<systemPropertyVariables> |
||||
<benchmarkReportDir>${project.build.directory}/reports/performance</benchmarkReportDir> |
||||
<project.version>${project.version}</project.version> |
||||
<git.dirty>${git.dirty}</git.dirty> |
||||
<git.commit.id>${git.commit.id}</git.commit.id> |
||||
<git.branch>${git.branch}</git.branch> |
||||
</systemPropertyVariables> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
||||
@ -1,14 +0,0 @@
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<configuration> |
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
||||
<encoder> |
||||
<pattern>%d %5p %40.40c:%4L - %m%n</pattern> |
||||
</encoder> |
||||
</appender> |
||||
|
||||
<root level="error"> |
||||
<appender-ref ref="console" /> |
||||
</root> |
||||
|
||||
</configuration> |
||||
Loading…
Reference in new issue