From 67547e61c6803f15246dfa6c3d1e2f045015b9bd Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 13 May 2020 21:29:02 +0200 Subject: [PATCH] Add JMH benchmark infrastructure Prior to this commit, the Spring Framework test suite would rely only on "Performance" tests associated with a specific CI build. As outlined in gh-24830, the way they're built and executed is not working well anymore. This commit introduces a new JMH benchmark infrastructure in the build. The goal here is not to run those benchmarks as part of a CI build, but rather provide a proper infrastructure for writing and locally running micro-benchmarks when working on specific optimizations. This commit adds and configures a Gradle JMH plugin to allow for JMH benchmark classes in Spring Framework modules (in `src/jmh/java` of each `spring-*` module). It's also relaxing the checkstyle rules for JMH classes, especially around Javadoc rules: this code is not meant to have Javadocs. Finally, this commit links to a new Wiki page on the project GitHub repository documenting the infrastructure and helping contributors to run and design benchmarks. See gh-24830 --- README.md | 4 ++++ build.gradle | 1 + gradle/spring-module.gradle | 10 ++++++++++ src/checkstyle/checkstyle-suppressions.xml | 3 +++ 4 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 88f119a7e19..43094aa5919 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ For access to artifacts or a distribution zip, see the [Spring Framework Artifac The Spring Framework maintains reference documentation ([published](https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/) and [source](src/docs/asciidoc)), Github [wiki pages](https://github.com/spring-projects/spring-framework/wiki), and an [API reference](https://docs.spring.io/spring-framework/docs/current/javadoc-api/). There are also [guides and tutorials](https://spring.io/guides) across Spring projects. +## Micro-Benchmarks + +See the [Micro-Benchmarks](https://github.com/spring-projects/spring-framework/wiki/Micro-Benchmarks) Wiki page. + ## Build from Source See the [Build from Source](https://github.com/spring-projects/spring-framework/wiki/Build-from-Source) Wiki page and the [CONTRIBUTING.md](CONTRIBUTING.md) file. diff --git a/build.gradle b/build.gradle index 590e43d6f2d..29c36b2b0e0 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,7 @@ plugins { id 'de.undercouch.download' version '4.0.4' id "io.freefair.aspectj" version '5.0.0' apply false id "com.github.ben-manes.versions" version '0.28.0' + id "me.champeau.gradle.jmh" version "0.5.0" apply false } ext { diff --git a/gradle/spring-module.gradle b/gradle/spring-module.gradle index 3291de9f332..ebf196ff1fa 100644 --- a/gradle/spring-module.gradle +++ b/gradle/spring-module.gradle @@ -1,7 +1,17 @@ apply plugin: 'org.springframework.build.compile' apply plugin: 'org.springframework.build.optional-dependencies' +apply plugin: 'me.champeau.gradle.jmh' apply from: "$rootDir/gradle/publications.gradle" +dependencies { + jmh 'org.openjdk.jmh:jmh-core:1.23' + jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.23' + jmh 'net.sf.jopt-simple:jopt-simple:4.6' +} +jmh { + duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE +} + jar { manifest.attributes["Implementation-Title"] = project.name manifest.attributes["Implementation-Version"] = project.version diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index 1c8fbe7218a..bb91954fce5 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -7,6 +7,9 @@ + + +