I have a performance critical piece of code that I would like to protect as a maven build step, i.e. JMH would run and check that performance hasn't degraded with the local changes.
How can I check such degradation using JMH?
I've found a few related links:
- Perf Testing in CI
- C++ CI with Perf Metrics
- Chapter: Perf in CI
- CI with JUnit and ContiPerf (uses
@Required()
annotation)
I've achieved automated performance testing before (though not with Java, and not in a CI environment). One key point to note is that you never run it as an absolute, since the machine that the benchmark is running on can vary. A BogoMips or test-dependent type of reference can be used as the relative comparison. The benchmark is then measured as some multiple of that reference time, with upper and lower bounds.
While you are typically wary of your benchmark slowing (degrading), it's also important to check the upper bound as well, as it may indicate an unexpected speedup (better hardware support), which should indicate a per-system/architecture bound needs to be checked.