= JMH
:page-aliases: Plugin_Jmh.adoc

You can use `JmhModule` to integrate JMH testing with Mill.

Example configuration:

.`build.mill`
[source,scala]
----
//| mvnDeps: ["com.lihaoyi::mill-contrib-jmh:$MILL_VERSION"]
package build

import mill.*, scalalib.*

import contrib.jmh.JmhModule

object foo extends ScalaModule with JmhModule {
  def scalaVersion = "2.13.16"
  def jmhCoreVersion = "1.35"
}
----

Here are some sample commands:

[source,console]
----
> mill foo.runJmh             # Runs all detected jmh benchmarks
> mill foo.listJmhBenchmarks  # List detected jmh benchmarks
> mill foo.runJmh -h          # List available arguments to runJmh
> mill foo.runJmh regexp      # Run all benchmarks matching `regexp`
----

For Scala JMH samples see https://github.com/sbt/sbt-jmh/tree/main/plugin/src/sbt-test/sbt-jmh/run/src/main/scala/org/openjdk/jmh/samples[sbt-jmh].
