blob: 4900a01a53e2086f296b0f3c9c12a212551cc5ff [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;
Matthias Andreas Benkardf90824b2024-06-23 16:42:11 +020016 private ExtLogRecord massivelyStructuredLogRecord;
Matthias Andreas Benkard47df8be2024-06-23 16:24:11 +020017 private Formatter formatter;
18
19 @Setup
20 public void setup() {
21 simpleLogRecord = FormatterTest.makeSimpleRecord();
22 structuredLogRecord = FormatterTest.makeStructuredRecord();
Matthias Andreas Benkardf90824b2024-06-23 16:42:11 +020023 massivelyStructuredLogRecord = FormatterTest.makeMassivelyStructuredRecord();
Matthias Andreas Benkard47df8be2024-06-23 16:24:11 +020024 formatter = new Formatter(List.of(), List.of());
25 }
26
27 @Benchmark
28 public void simpleLogRecord(Blackhole blackhole) {
29 blackhole.consume(formatter.format(simpleLogRecord));
30 }
31
32 @Benchmark
33 public void structuredLogRecord(Blackhole blackhole) {
34 blackhole.consume(formatter.format(structuredLogRecord));
35 }
Matthias Andreas Benkardf90824b2024-06-23 16:42:11 +020036
37 @Benchmark
38 public void massivelyStructuredLogRecord(Blackhole blackhole) {
39 var f = formatter.format(massivelyStructuredLogRecord);
40 blackhole.consume(f);
41 }
Matthias Andreas Benkard47df8be2024-06-23 16:24:11 +020042}