blob: 1a1c17c8b6d16b7f103b867a08f695bc08f80edc [file] [log] [blame]
Matthias Andreas Benkard47df8be2024-06-23 16:24:11 +02001package eu.mulk.quarkus.googlecloud.jsonlogging;
2
3import java.util.List;
4import org.jboss.logmanager.ExtLogRecord;
5import org.openjdk.jmh.annotations.*;
6import org.openjdk.jmh.infra.Blackhole;
7
8@Warmup(iterations = 5, time = 1)
9@Measurement(iterations = 10, time = 1)
10@Fork(value = 1)
11@State(org.openjdk.jmh.annotations.Scope.Benchmark)
12public class FormatterBenchmark {
13
14 private ExtLogRecord simpleLogRecord;
15 private ExtLogRecord structuredLogRecord;
16 private Formatter formatter;
17
18 @Setup
19 public void setup() {
20 simpleLogRecord = FormatterTest.makeSimpleRecord();
21 structuredLogRecord = FormatterTest.makeStructuredRecord();
22 formatter = new Formatter(List.of(), List.of());
23 }
24
25 @Benchmark
26 public void simpleLogRecord(Blackhole blackhole) {
27 blackhole.consume(formatter.format(simpleLogRecord));
28 }
29
30 @Benchmark
31 public void structuredLogRecord(Blackhole blackhole) {
32 blackhole.consume(formatter.format(structuredLogRecord));
33 }
34}