lbradstreet commented on a change in pull request #9129: URL: https://github.com/apache/kafka/pull/9129#discussion_r540360441
########## File path: jmh-benchmarks/README.md ########## @@ -1,10 +1,69 @@ -### JMH-Benchmark module +### JMH-Benchmarks module This module contains benchmarks written using [JMH](https://openjdk.java.net/projects/code-tools/jmh/) from OpenJDK. Writing correct micro-benchmarks in Java (or another JVM language) is difficult and there are many non-obvious pitfalls (many due to compiler optimizations). JMH is a framework for running and analyzing benchmarks (micro or macro) written in Java (or another JVM language). +### Running benchmarks + +If you want to set specific JMH flags or only run certain benchmarks, passing arguments via +gradle tasks is cumbersome. These are simplified by the provided `jmh.sh` script. + +The default behavior is to run all benchmarks: + + ./jmh-benchmarks/jmh.sh + +Pass a pattern or name after the command to select the benchmarks: + + ./jmh-benchmarks/jmh.sh LRUCacheBenchmark + +Check which benchmarks that match the provided pattern: + + ./jmh-benchmarks/jmh.sh -l LRUCacheBenchmark + +Run a specific test and override the number of forks, iterations and warm-up iteration to `2`: + + ./jmh-benchmarks/jmh.sh -f 2 -i 2 -wi 2 LRUCacheBenchmark + +Run a specific test with async and GC profilers on Linux and flame graph output: + + ./jmh-benchmarks/jmh.sh -prof gc -prof async:libPath=/path/to/libasyncProfiler.so\;output=flamegraph LRUCacheBenchmark + +The following sections cover async profiler and GC profilers in more detail. + +### Using JMH with async profiler + +It's good practice to check profiler output for microbenchmarks in order to verify that they are valid. Review comment: How about: "It's good practice to check profiler output for microbenchmarks in order to verify that they represent application behavior and measure what you expect to measure. Some example pitfalls include the use of expensive mocks or accidental inclusion of test setup code in the benchmarked code." ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org