test: Add benchmarks.

The benchmarks can be run using 'mvn verify -Pbenchmark'.

Change-Id: I13058f52bea77aa3cb4f1967126c28e1e98d1838
diff --git a/README.adoc b/README.adoc
index 6b479ca..7048262 100644
--- a/README.adoc
+++ b/README.adoc
@@ -446,3 +446,22 @@
   }
 }
 ----
+
+
+== Development
+
+=== Running the Tests
+
+To run the **test suite**, run:
+
+[source,shell]
+----
+$ mvn verify
+----
+
+To run the **benchmarks**, run:
+
+[source,shell]
+----
+$ mvn verify -Pbenchmark
+----
diff --git a/core/pom.xml b/core/pom.xml
index a75acd5..38f7ea5 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -55,12 +55,38 @@
       <version>5.10.2</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+        <groupId>org.openjdk.jmh</groupId>
+        <artifactId>jmh-core</artifactId>
+        <version>1.35</version>
+        <scope>test</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.openjdk.jmh</groupId>
+        <artifactId>jmh-generator-annprocess</artifactId>
+        <version>1.35</version>
+        <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
     <plugins>
 
       <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <annotationProcessorPaths>
+            <path>
+              <groupId>org.openjdk.jmh</groupId>
+              <artifactId>jmh-generator-annprocess</artifactId>
+              <version>1.35</version>
+            </path>
+          </annotationProcessorPaths>
+        </configuration>
+      </plugin>
+
+      <plugin>
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <archive>
@@ -73,10 +99,54 @@
 
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>3.2.5</version>
       </plugin>
 
     </plugins>
   </build>
 
+  <profiles>
+
+    <profile>
+      <id>benchmark</id>
+
+      <build>
+        <plugins>
+
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>true</skipTests>
+            </configuration>
+          </plugin>
+
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>run-benchmarks</id>
+                <phase>integration-test</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <classpathScope>test</classpathScope>
+                  <executable>java</executable>
+                  <arguments>
+                    <argument>-classpath</argument>
+                    <classpath />
+                    <argument>org.openjdk.jmh.Main</argument>
+                    <argument>.*</argument>
+                  </arguments>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+
+        </plugins>
+      </build>
+    </profile>
+
+  </profiles>
+
 </project>
diff --git a/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterBenchmark.java b/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterBenchmark.java
new file mode 100644
index 0000000..1a1c17c
--- /dev/null
+++ b/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterBenchmark.java
@@ -0,0 +1,34 @@
+package eu.mulk.quarkus.googlecloud.jsonlogging;
+
+import java.util.List;
+import org.jboss.logmanager.ExtLogRecord;
+import org.openjdk.jmh.annotations.*;
+import org.openjdk.jmh.infra.Blackhole;
+
+@Warmup(iterations = 5, time = 1)
+@Measurement(iterations = 10, time = 1)
+@Fork(value = 1)
+@State(org.openjdk.jmh.annotations.Scope.Benchmark)
+public class FormatterBenchmark {
+
+  private ExtLogRecord simpleLogRecord;
+  private ExtLogRecord structuredLogRecord;
+  private Formatter formatter;
+
+  @Setup
+  public void setup() {
+    simpleLogRecord = FormatterTest.makeSimpleRecord();
+    structuredLogRecord = FormatterTest.makeStructuredRecord();
+    formatter = new Formatter(List.of(), List.of());
+  }
+
+  @Benchmark
+  public void simpleLogRecord(Blackhole blackhole) {
+    blackhole.consume(formatter.format(simpleLogRecord));
+  }
+
+  @Benchmark
+  public void structuredLogRecord(Blackhole blackhole) {
+    blackhole.consume(formatter.format(structuredLogRecord));
+  }
+}
diff --git a/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterTest.java b/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterTest.java
index 49cda39..91cc8e4 100644
--- a/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterTest.java
+++ b/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterTest.java
@@ -1,20 +1,19 @@
 package eu.mulk.quarkus.googlecloud.jsonlogging;
 
+import static org.junit.jupiter.api.Assertions.assertLinesMatch;
+
 import jakarta.json.Json;
+import java.util.Collection;
+import java.util.List;
 import org.jboss.logmanager.ExtLogRecord;
 import org.jboss.logmanager.Level;
 import org.junit.jupiter.api.Test;
 
-import java.util.Collection;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertLinesMatch;
-
 class FormatterTest {
 
   @Test
   void simpleRecord() {
-    var logRecord = new ExtLogRecord(Level.INFO, "Hello, world!", FormatterTest.class.getName());
+    var logRecord = makeSimpleRecord();
 
     var formatter = new Formatter(List.of(), List.of());
     var formattingResult = formatter.format(logRecord);
@@ -34,6 +33,10 @@
         List.of(formattingResult));
   }
 
+  static ExtLogRecord makeSimpleRecord() {
+    return new ExtLogRecord(Level.INFO, "Hello, world!", FormatterTest.class.getName());
+  }
+
   @Test
   void structuredRecord() {
     var parameterProvider =
@@ -55,13 +58,7 @@
           }
         };
 
-    var logRecord = new ExtLogRecord(Level.INFO, "Hello, world!", FormatterTest.class.getName());
-    logRecord.setParameters(
-        new Object[] {
-          (StructuredParameter)
-              () -> Json.createObjectBuilder().add("one", 1).add("two", 2.0).add("yes", true),
-          Label.of("a", "b")
-        });
+    var logRecord = makeStructuredRecord();
 
     var formatter = new Formatter(List.of(parameterProvider), List.of(labelProvider));
     var formattingResult = formatter.format(logRecord);
@@ -85,4 +82,15 @@
                 + "\\}\n"),
         List.of(formattingResult));
   }
+
+  static ExtLogRecord makeStructuredRecord() {
+    var logRecord = makeSimpleRecord();
+    logRecord.setParameters(
+        new Object[] {
+          (StructuredParameter)
+              () -> Json.createObjectBuilder().add("one", 1).add("two", 2.0).add("yes", true),
+          Label.of("a", "b")
+        });
+    return logRecord;
+  }
 }
diff --git a/pom.xml b/pom.xml
index fe93b23..b346411 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,6 +61,7 @@
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 
     <compiler-plugin.version>3.13.0</compiler-plugin.version>
+    <exec-maven-plugin.version>3.2.0</exec-maven-plugin.version>
     <failsafe-plugin.version>${surefire-plugin.version}</failsafe-plugin.version>
     <flatten-plugin.version>1.6.0</flatten-plugin.version>
     <google-java-format.version>1.15.0</google-java-format.version>
@@ -197,6 +198,12 @@
         </configuration>
       </plugin>
 
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>${exec-maven-plugin.version}</version>
+      </plugin>
+
     </plugins>
   </build>