The tests are written as JMH benchmarks. They can be developed and executed as usual in your IDE. However, they are not executed during regular build as unit tests when a mvn test is running. Instead, to execute the performance tests, one should build a jar file with one of the profiles mentioned below and run it.
To allow performance testing of different Hibernate Validator versions there are multiple profiles configured. Choosing a profile executes the tests against the specified Hibernate Validator or BVal version, respectively. The defined profiles are:
Some tips before you start:
The following command line will run all performance tests listed in the main method of TestRunner class:
mvn clean package -Dvalidator=hv-current
java -jar target/hibernate-validator-performance-hv-current.jar
It will generate a set of reports from each test execution. Currently, all test results information are inside the following generated file:
target/jmh-results.json
List of available profilers:
Profiler | Description |
---|---|
org.openjdk.jmh.profile.ClassloaderProfiler | Classloader profiling via standard MBeans |
org.openjdk.jmh.profile.CompilerProfiler | JIT compiler profiling via standard MBeans |
org.openjdk.jmh.profile.GCProfiler | GC profiling via standard MBeans |
org.openjdk.jmh.profile.HotspotClassloadingProfiler | HotSpot ™ classloader profiling via implementation-specific MBeans |
org.openjdk.jmh.profile.HotspotCompilationProfiler | HotSpot ™ JIT compiler profiling via implementation-specific MBeans |
org.openjdk.jmh.profile.HotspotMemoryProfiler | HotSpot ™ memory manager (GC) profiling via implementation-specific MBeans |
org.openjdk.jmh.profile.HotspotRuntimeProfiler | HotSpot ™ runtime profiling via implementation-specific MBeans |
org.openjdk.jmh.profile.HotspotThreadProfiler | HotSpot ™ threading subsystem via implementation-specific MBeans |
org.openjdk.jmh.profile.StackProfiler | Simple and naive Java stack profiler |
If you want to run one of those profilers - pass it as parameter when running a jar file. For example:
java -jar target/hibernate-validator-performance-hv-current.jar -prof org.openjdk.jmh.profile.StackProfiler
To run a specific benchmark:
java -jar target/hibernate-validator-performance.jar CascadedValidation
mkdir reports
for impl in "bval-1.1.2" "hv-5.4" "hv-current"; do
mvn -Dvalidator=${impl} package ; java -jar target/hibernate-validator-performance-${impl}.jar -rff reports/${impl}-jmh-results.json
done
At the moment the following benchmarks are defined:
A simple bean with a random number of failing constraints gets initialized and validated. The test is once executed with a shared ValidatorFactory and once the factory is recreated on each invocation.
Simple bean with cascaded validation which gets executed over and over.
Validation of a bean containing a lot of beans to cascade to.
This test has a few more constraints than the previous one, allowing to test our hypothesis in more realistic situation.
A number of _TestEntity_s is created where each entity contains a property for each built-in constraint type and also a reference to another TestEntity. All constraints are evaluated by a single ConstraintValidator implementation which fails a specified percentage of the validations.
When adding new performance tests, note the sources structure of this module:
java/
: main sources that contain the test runnerjakarta/
: performance tests based on the jakarta.validation
namespace and that are applicable to the Jakarta
Validation spec implementation.javax/
: performance tests based on the javax.validation
namespace and that are applicable to the Java Bean
Validation spec implementation for versions 1.0 and 1.1.javax-bv2/
performance tests based on the javax.validation
namespace and that are applicable to the Java Bean
Validation spec implementation for version 2.0.Hence, when a new test is added, consider adding it to the jakarta
and javax
directories depending on the tested
functionality.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。