diff --git a/penna-core/src/jmh/java/penna/core/logger/LoggerPerformanceTest.java b/penna-core/src/jmh/java/penna/core/logger/LoggerPerformanceTest.java index 760a3e7..18038aa 100644 --- a/penna-core/src/jmh/java/penna/core/logger/LoggerPerformanceTest.java +++ b/penna-core/src/jmh/java/penna/core/logger/LoggerPerformanceTest.java @@ -5,6 +5,7 @@ import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.encoder.JsonEncoder; import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.classic.util.LogbackMDCAdapter; import ch.qos.logback.core.OutputStreamAppender; import ch.qos.logback.core.encoder.Encoder; import net.logstash.logback.encoder.LogstashEncoder; @@ -99,6 +100,7 @@ private Encoder getLogstashEncoder() { @Setup public void setup() { context.setName("JMH"); + context.setMDCAdapter(new LogbackMDCAdapter()); logger = context.getLogger("jmh.test.logback"); logger.setLevel(Level.INFO); OutputStreamAppender appender = new LogbackDevNullAppender(); @@ -140,6 +142,7 @@ public void setup() throws IOException { logger = cache.getLoggerAt("jmh", "test", "penna"); } + @TearDown public void tearDown() throws IOException { fos.close(); @@ -151,10 +154,10 @@ public void penna(PennaState state, TestBehavior tb) throws IOException { tb.log(state.logger); } -// @Benchmark -// public void logback(LogbackState state, TestBehavior tb) throws IOException { -// tb.log(state.logger); -// } + @Benchmark + public void logback(LogbackState state, TestBehavior tb) throws IOException { + tb.log(state.logger); + } @Test public void runBenchmarks() throws Exception { @@ -171,7 +174,7 @@ public void runBenchmarks() throws Exception { .addProfiler("gc") .addProfiler("perfnorm") .addProfiler("perfasm", "tooBigThreshold=2100") - .threads(4) + .threads(1) .jvm("/usr/lib/jvm/java-21-jetbrains/bin/java") .jvmArgs("-Xmx8192m") .build();