Skip to content

DATAMONGO-1720 - Add JMH based benchmark module #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from

Conversation

christophstrobl
Copy link
Member

⚠️ commits 67376b8 & 05a3cc7 need to be dropped when merging ⚠️


Running Benchmarks

Running benchmarks is disabled by default and can be activated via the benchmarks profile.
To run the benchmarks with default settings use.

mvn -P benchmarks clean test

A basic report will be printed to the CLI.

# 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.

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.

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 via the publishTo command line argument.

mvn -P benchmarks clean test -D publishTo=mongodb://127.0.0.1:27017

ℹ️ 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.

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)

Run the benchmark via the maven profile "benchmarks":

    mvn -P benchmarks clean test

Or run them customized:

    mvn -P benchmarks -DwarmupIterations=2 -DmeasurementIterations=5 -Dforks=1 clean test
…ime & benchmark to run.

Excution time can be set via
  -D warmupTime=
  -D measurementTime=

Allow selecting a class or a single benchmark via -D benchmark=classname#method. Just skip the method name in order to run all benchmarks of a given class.
Update JavaDoc, rename properties
}

@Benchmark // DATAMONGO-1720
public Customer readObjectWith2tPropertiesAnd1NestedObject() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superfluous "t".

Enhance benchmark statistics with Git/working tree details. Specify byte encoding for JSON to byte encoder.
Add status code check to HttpResultsWriter to verify that the results were accepted. Convert spaces to tabs in pom.xml.
@christophstrobl
Copy link
Member Author

backported recent changes to spring-projects/spring-data-mongodb/issue/1.10.x/DATAMONGO-1720 brach.

mp911de pushed a commit that referenced this pull request Jul 13, 2017
Run the benchmark via the maven profile "benchmarks":

    mvn -P benchmarks clean test

Or run them customized:

    mvn -P benchmarks -DwarmupIterations=2 -DmeasurementIterations=5 -Dforks=1 clean test

Original pull request: #483.
mp911de added a commit that referenced this pull request Jul 13, 2017
Enhance benchmark statistics with Git/working tree details. Specify byte encoding for JSON to byte encoder.
Add status code check to HttpResultsWriter to verify that the results were accepted. Convert spaces to tabs in pom.xml.

Original pull request: #483.
mp911de pushed a commit that referenced this pull request Jul 13, 2017
Run the benchmark via the maven profile "benchmarks":

    mvn -P benchmarks clean test

Or run them customized:

    mvn -P benchmarks -DwarmupIterations=2 -DmeasurementIterations=5 -Dforks=1 clean test

Origin pull request: #483.
mp911de added a commit that referenced this pull request Jul 13, 2017
Enhance benchmark statistics with Git/working tree details. Specify byte encoding for JSON to byte encoder.
Add status code check to HttpResultsWriter to verify that the results were accepted. Convert spaces to tabs in pom.xml.

Original pull request: #483.
mp911de pushed a commit that referenced this pull request Jul 13, 2017
Run the benchmark via the maven profile "benchmarks":

    mvn -P benchmarks clean test

Or run them customized:

    mvn -P benchmarks -DwarmupIterations=2 -DmeasurementIterations=5 -Dforks=1 clean test

Original pull request: #483.
mp911de added a commit that referenced this pull request Jul 13, 2017
Enhance benchmark statistics with Git/working tree details. Specify byte encoding for JSON to byte encoder.
Add status code check to HttpResultsWriter to verify that the results were accepted. Convert spaces to tabs in pom.xml.

Original pull request: #483.
@mp911de mp911de closed this Jul 13, 2017
@mp911de mp911de deleted the issue/DATAMONGO-1720 branch July 13, 2017 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants